Überprüfung der länge des Dateinamens

M

medop

Neues Mitglied
Thread Starter
Dabei seit
15.07.2003
Beiträge
14
Reaktionspunkte
0
Überprüfung der länge des Dateinamens / Speichern + Drucken von Quarkdokumenten

Hallo zusammen.

Ich habe ein Droplet geschrieben welches sich wie folgt verhällt:

1. eine Quarkdatei wird auf das Droplt gezogen
2. eine Dialogbox geht auf in der ich einen Zielordner für die neu zu speichernde Quarkdatei angeben kann
3. eine weitere Dialogbox geht auf in der ich bestimmen kann welche Zeichen noch zusätzlich nach den Original-Dateinamen eingefügt werden.
4. das Dokument wird geöffnet
5. das Dokument wird mit einem neuen Dateinamen gespeichert (Musterdokument_S_01)
-> der neue Dateiname setzt sich aus dem Original-Dokumentnamen, die vorher bestimmten zusätzlichen Zeichen und die Seitenzahl zusammen
6. die Seite wird gedruckt

Mein Problem ist die Länge des Dateinamens. Wie kann ich eine Fehlermeldung "zu langer Dateiname" an der Stellen einfügen wo ich die zusätzlichen Zeichen eingeben kann.

Ich bin für jede Anregung dankbar.
 
Zuletzt bearbeitet:
...

Hallo medop,

mit einem on error handler. Möchtest Du Dein Script hier pasten? Ich weiß der Code tag mag nicht so recht. Eventuell PHP oder den Zitat tag verwenden.

Gruß Andi
 
So, jetzt stelle ich mal hier mein Script zu schau.
Einige Teile dieses Script sind aus anderen zusammengetragen und andere sind von mir geschrieben oder an meine Bedürfnisse angepasst.

Was ich noch einbauen möchte ist das an der Stelle, in der der Zielordner ausgewählt wird, der Ordner als Vorgabe gegeben wird in dem sich das Quarkdokument befindet.
Und ich möchte noch das ich mit dem Script auch Doppelseiten ausgeben kann. Ich müsste dann wohl die Druckereinstellung dahingehend überprüfen lassen, was wie ich denke nicht so schwer ist zu lösen, und im Dateinamen müsste es dann folgender weise so heißen "Dateiname_S_02_03". Das würde ich noch hinbekommen, ich wüsste aber auf anhieb nicht wie ich das Problem lösen soll wenn der name so lauten müßte "Dateiname_S_16_01".

Ich bin für jede Anregung offen. Danke schon im vorraus.

PHP:
-- This droplet processes both files or folders of files dropped onto the applet 
on open these_items
	
	repeat with i from 1 to the count of these_items
		set this_item to (item i of these_items)
		set the item_info to info for this_item
		
		if folder of the item_info is true then
			process_folder(this_item)
		else if (alias of the item_info is false) then
			my process_item(this_item)
		end if
	end repeat
	
end open

-- this sub-routine processes folders 
on process_folder(this_folder)
	
	set these_items to list folder this_folder without invisibles
	repeat with i from 1 to the count of these_items
		set this_item to alias ((this_folder as text) & (item i of these_items))
		set the item_info to info for this_item
		if folder of the item_info is true then
			process_folder(this_item)
		else if (alias of the item_info is false) then
			my process_item(this_item)
		end if
		
	end repeat
end process_folder

-- this sub-routine prints the files 
on process_item(this_item)
	
	set document_path to (choose folder with prompt "Wohin sollen die Quark-Dokumente gespeichert werden?") as string
	set addition to display dialog "Was soll eingefügt werden?  (Leerzeichen beachten!)" default answer "" buttons {"Romane", "Standard (_S_)", "Eingabe"}
	set addition_entered to text returned of addition
	set the_button_pressed to button returned of addition
	
	if the_button_pressed is "Romane" then
		set add_name to "_"
	else
		if the_button_pressed is "Standard (_S_)" then
			set add_name to "_S_"
		else
			if the_button_pressed is "Eingabe" then
				set add_name_space to (choose from list {"Eingabe", "*Eingabe*", "*Eingabe", "Eingabe*"} with prompt "* = Leerzeichen")
				set add_name_entered to add_name_space as text
				if add_name_entered is "Eingabe" then
					set add_name to addition_entered
				else
					if add_name_entered is "*Eingabe*" then
						set add_name to "_" & addition_entered & "_"
					else
						if add_name_entered is "*Eingabe" then
							set add_name to "_" & addition_entered
						else
							if add_name_entered is "Eingabe*" then
								set add_name to addition_entered & "_"
							end if
						end if
					end if
				end if
			end if
		end if
	end if
	
	tell application "Finder"
		--open item this_item
		try
			set File_Name to name of file this_item as text
		on error
			display dialog "Es gibt Probleme den Dateinamen zu ermitteln."
		end try
	end tell
	
	tell application "QuarkXPress Passportª 4.11"
		activate
		open this_item use doc prefs yes
		tell document 1
			repeat with i from 1 to count of pages
				set page_display_num to name of page i
				set dest_path to coerce document_path to string
				if page_display_num is "1" or page_display_num is "2" or page_display_num is "3" or page_display_num is "4" or page_display_num is "5" or page_display_num is "6" or ¬
					page_display_num is "7" or page_display_num is "8" or page_display_num is "9" then
					save in (dest_path & File_Name & add_name & "0" & page_display_num)
					print page i
				else
					save in (dest_path & File_Name & add_name & page_display_num)
					print page i
				end if
			end repeat
		end tell
		
		close document 1 saving no
		
	end tell
	
end process_item
 
Zuletzt bearbeitet:
Das Problem mit dem zu langen Dateinamen habe ich nun gelöst.
(siehe neues Script)
Jetzt gehe ich an die anderen Probleme.

NEUES SCRIPT (15.04.04) - Ich hatte einen Fehler eingebaut

PHP:
--_This_droplet_processes_both_files_or_folders_of_files_dropped_onto_the_applet_ 
on open these_items
	
	repeat with i from 1 to the count of these_items
		set this_item to (item i of these_items)
		set the item_info to info for this_item
		
		if folder of the item_info is true then
			process_folder(this_item)
		else if (alias of the item_info is false) then
			my process_item(this_item)
		end if
	end repeat
	
end open

--_this_sub-routine_processes_folders_ 
on process_folder(this_folder)
	
	set these_items to list folder this_folder without invisibles
	repeat with i from 1 to the count of these_items
		set this_item to alias ((this_folder as text) & (item i of these_items))
		set the item_info to info for this_item
		if folder of the item_info is true then
			process_folder(this_item)
		else if (alias of the item_info is false) then
			my process_item(this_item)
		end if
		
	end repeat
end process_folder

--_this_sub-routine_prints_the_files_ 
on process_item(this_item)
	
	tell application "Finder"
		--open_item_this_item 
		try
			set file_name to name of file this_item as text
		on error
			display dialog "Es gibt Probleme den Dateinamen zu ermitteln."
		end try
	end tell
	
	set document_path to (choose folder with prompt "Wohin sollen die Quark-Dokumente gespeichert werden?") as string
	
	set too_long to false
	repeat until too_long is true
		set addition to display dialog "Was soll eingefügt werden?" default answer "" buttons {"Romane", "Standard (_S_)", "Eingabe"}
		set addition_entered to text returned of addition
		set filename_length to the count of file_name
		set max_filename_length to 31
		
		set the_button_pressed to button returned of addition
		
		if the_button_pressed is "Romane" then
			set add_name to "_"
		else
			if the_button_pressed is "Standard (_S_)" then
				set add_name to "_S_"
			else
				if the_button_pressed is "Eingabe" then
					set add_name_space to (choose from list {"Eingabe", "*Eingabe*", "*Eingabe", "Eingabe*"} with prompt "* = Leerzeichen")
					set add_name_entered to add_name_space as text
					if add_name_entered is "Eingabe" then
						set add_name to addition_entered
					else
						if add_name_entered is "*Eingabe*" then
							set add_name to "_" & addition_entered & "_"
						else
							if add_name_entered is "*Eingabe" then
								set add_name to "_" & addition_entered
							else
								if add_name_entered is "Eingabe*" then
									set add_name to addition_entered & "_"
								end if
							end if
						end if
					end if
				end if
			end if
		end if
		set add_length to the count of add_name
		if add_length is greater than max_filename_length - filename_length - 4 then
			display dialog "Der eingegebene Text ist zu lang!"
			set too_long to false
		else
			set too_long to true
		end if
	end repeat
	
	tell application "QuarkXPress Passport™ 4.11"
		activate
		open this_item use doc prefs yes
		tell document 1
			repeat with i from 1 to count of pages
				set page_display_num to name of page i
				set dest_path to coerce document_path to string
				if page_display_num is "1" or page_display_num is "2" or page_display_num is "3" or page_display_num is "4" or page_display_num is "5" or page_display_num is "6" or ¬
					page_display_num is "7" or page_display_num is "8" or page_display_num is "9" then
					save in (dest_path & file_name & add_name & "0" & page_display_num)
					print page i
				else
					save in (dest_path & file_name & add_name & page_display_num)
					print page i
				end if
			end repeat
		end tell
		
		close document 1 saving no
		
	end tell
	
end process_item
 
Zuletzt bearbeitet:
Zurück
Oben Unten