I have looked and searched for a solution but I am obviously missing something here. This folder action prints then duplicates the added file. What I need is that once the file is duplicated, HOW do I rename it to the first word of the original file name? I can parse the first word just fine with delimiters, but renaming the actual file eludes me.
(* Script runs when a new pdf is placed in folder. The PDF is printed, when "yes" is selected in previous script, to the default printer. Then it is copied to the selected folder on network drive "EPS ADS" and deleted from the local folder.
*)
-- Define destination OUT folder
property dest_OUT_Folder : "Art Server:{Pre-press Folders}: PDF Proofs: RICHARD:Out:"
-- this handler is triggered by adding new PDF(s) to the attached folder
on adding folder items to this_folder after receiving these_items
-- This section allows variables defined in previous script to be passed to this script
set myScript to load script alias "Macintosh HD:Applications:Creator Professional 8.0.3:MultiAd Creator Add-Ons:Script Menu Folder:FinalPDFtoMain.scpt"
set PDF_destination_folder to myScript's PDF_destination_folder
set PrintPDF to myScript's PrintPDF
set fileList to items of these_items
-- end section
-- repeat for each PDF added
repeat with i from 1 to (count of fileList)
set itemToCopy to item i of fileList as alias
-- Error handling
try
if PrintPDF is true then
-- Print PDF
tell application "Adobe Acrobat Professional"
open itemToCopy
print pages active doc PS Level 2 with shrink to fit
close active doc
end tell
-- end Print PDF
end if
set volume alert volume 0
tell application "Finder"
duplicate itemToCopy to alias PDF_destination_folder with replacing
--RIGHT HERE I want to rename the new duplicated file to the first word of the whole file name.
-- move added PDF(s) to the trash
delete itemToCopy
end tell
set volume alert volume 90
on error the error_message number the error_number
display dialog "Error: " & the error_number & ". " & the error_message buttons {"OK"} default button 1
end try
end repeat
display dialog "New PDF(s) was detected, then copied to " & PDF_destination_folder & " folder and then deleted from local folder." giving up after 3
end adding folder items to