I have a script that imposes a file onto a printing plate using Preps 5…I have this script set to a folder action so when I drop a file in the folder it auto imposes the file…The script works great the file imposes and sends the images to the printer.
my problem is that the name of the file I drop in the folder action doesn’t show up on the plate ID…It just says untitled…I can’t save the file so all it will say is Untitled…so I wrote this little line (set jobname to newName as string) this should take the name of the job and place it in the ID slot…but it doesn’t…
Can anyone tell me where I’m going wrong or give me some suggestions on how to fix this little problem…the Scripting applications on this site has the dictionary for this application Preps 5…I thank anyone for any help I can get…My os is Tiger 10.4.7…
property done_foldername : "Finished_Pdfs"
property out_path : "brisque15.1.0:CP_Plates_1:"
property jobname : " "
property type_list : {"PDF"}
property extension_list : {"pdf"}
on adding folder items to this_folder after receiving these_items
tell application "Finder"
if not (exists folder done_foldername of this_folder) then
make new folder at this_folder with properties {name:done_foldername}
set current view of container window of this_folder to list view
end if
set the target_folder to folder done_foldername of this_folder
end tell
set outpath to out_path as string
try
repeat with i from 1 to number of items in these_items
set this_item to item i of these_items
set the item_info to the info for this_item
if (alias of the item_info is false and the file type of the item_info is in the type_list) or (the name extension of the item_info is in the extension_list) then
tell application "Finder"
my resolve_conflicts(this_item, target_folder)
set the target_file to (move this_item to the target_folder with replacing) as alias
end tell
set file_name to the name of item_info
process_item(file_name, outpath)
end if
end repeat
on error error_message number error_number
if the error_number is not -128 then
tell application "Finder"
activate
display dialog error_message buttons {"Cancel"} default button 1 giving up after 120
end tell
end if
end try
end adding folder items to
on resolve_conflicts(this_item, target_folder)
tell application "Finder"
set the file_name to the name of this_item
if (exists document file file_name of target_folder) then
set file_extension to the name extension of this_item
if the file_extension is "" then
set the trimmed_name to the file_name
else
set the trimmed_name to text 1 thru -((length of file_extension) + 2) of the file_name
end if
set the name_increment to 1
repeat
set the new_name to (the trimmed_name & "." & (name_increment as string) & "." & file_extension) as string
if not (exists document file new_name of the target_folder) then
-- rename to conflicting file
set the name of document file file_name of the target_folder to the new_name
exit repeat
else
set the name_increment to the name_increment + 1
end if
end repeat
end if
end tell
end resolve_conflicts
on process_item(this_item, outpath)
try
set this_item to this_item as string
set outpath to outpath as string
with timeout of 900 seconds
set inputfiles to this_item
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to {".pdf"}
set theFile to this_item as string --> Test.pdf
set nameWithoutExtension to first text item of theFile
set newName to nameWithoutExtension & "_I.pdf"
set AppleScript's text item delimiters to oldDelims
tell application "Preps 5"
launch -- always use with Folder Actions
say "Starting Script"
if exists front job then
close front job
activate
end if
if not (exists (front job)) then
activate
else
display dialog "This script will only work if there" & return & ¬
"is no job currently open in Preps :-)" buttons {"OK"} default button 1 with icon 1
return
do shell script "sleep 5"
end if
end tell
tell application "Preps 5"
set jobname to newName as string
make new job with properties {name:jobname, workflow:PDF}
say "new job created"
delay 2
insert inputfiles in the runlist of the front job
say "pages added"
delay 2
autoselect signatures for the front job using "Plzeek"
say "signatures added"
delay 2
print the front job saving as PDF file saving in outpath to device "brisque" filename newName
say "job printed"
end tell
end timeout
on error error_message
tell application "Finder"
activate
display dialog error_message buttons {"Cancel"} default button 1 giving up after 120
end tell
end try
end process_item