I have an applescript droplet that renames and files images. When I drop the images onto this droplet, it will rename the first one and then give me an error -4960, stopping the script before it files even one image. If I try dropping images onto the droplet a second time after they've been renamed and caused an error, the script then cooperates and files the images. If I do the renaming and filing script as two separate droplets instead of one, it works perfectly. I'm assuming I have something wrong that is preventing the renaming and filing parts of the script from working together. It may be one of those obvious things that I just can't see, but I'd really appreciate it if someone could help me see why it's not working.
on open droppedfiles
repeat with afile in droppedfiles
--USING THE FINDER TO RENAME THE FILE, ADDING _s_4c to THE IMAGE NAME
tell application "Finder"
activate
set fileToMove to afile
set fileToMove_Name to name of fileToMove
set fileExt to name extension of fileToMove
set oldDelims to AppleScript's text item delimiters
try
--ELIMINATING _4c on IMAGES THAT ALREADY HAD _4c IN FILE NAME BEFORE PROCESSING
if name of fileToMove contains "_4c" and name of fileToMove does not contain "_s_4c" then
set AppleScript's text item delimiters to {"_4c"}
--ELIMINATING DOUBLE _s_4c on IMAGES THAT ALREADY HAD _s_4c IN FILE NAME BEFORE PROCESSING
else if name of fileToMove contains "_s_4c" then
set AppleScript's text item delimiters to {"_s_4c"}
--FOR IMAGES THAT DIDN'T HAVE _s_4c IN FILE NAME BEFORE PROCESSING
else if name of fileToMove does not contain "_s_4c" or "_4c" then
set AppleScript's text item delimiters to {"."}
end if
set fileName to name of fileToMove --> ex. Disneyland.tif
set nameWithoutExtension to first text item of fileName --> Disneyland
set newName to nameWithoutExtension & "_s_4c" & "." & fileExt --> Disneyland_s_4c.tif
set name of fileToMove to newName
--RESETTING APPLESCRIPT'S TEXT ITEM DELIMITERS AND NAME
set AppleScript's text item delimiters to oldDelims
set name of fileToMove to fileToMove_Name
--TELLING FINDER TO RESET APPLESCRIPT'S TEXT ITEM DELIMITERS IF THERE'S AN ERROR
on error
set AppleScript's text item delimiters to oldDelims
end try
end tell
--FILING THE IMAGES
tell application "Finder"
activate
set fileToMove to afile
set fileToMove_Name to name of fileToMove as string
set fileExt to name extension of fileToMove as string
--DUPLICATE FILE TO WEB CONVERT FOLDER ON R DRIVE
try
if fileExt is "tif" then
duplicate fileToMove to alias "Volumes:sdrive:IMAGES_FROM PREPRESS:z_DEBORAH_CONVERT and FILE:"
else
move fileToMove to alias "Volumes:server1:Advertising Department:5_ADVERTISING DEPT - PREPRESS:1_ADV IMAGE PROCESSING:2_PROCESSING:Processing:Scripts:Convert:"
end if
--Moving file to the "File Manually in RDRIVE & 1_4c IMAGES folder" inside the Processing Folder if there is an error
on error
move fileToMove to alias "Volumes:server1:Advertising Department:5_ADVERTISING DEPT - PREPRESS:1_ADV IMAGE PROCESSING:2_PROCESSING:Processing:Scripts:File Manually in RDRIVE & 1_4c IMAGES:" with replacing
end try
--ONTO FILING INTO THE 1_4C IMAGES FOLDERS
try
--DECLARING LISTS OF STRINGS OF CHARACTERS FOR THE COMPUTER TO LOOK FOR
--AG Files
set AG00string to {"AG00", "AG01", "AG02", "AG03"}
set AG04string to {"AG04", "AG05", "AG06", "AG07", "AG08", "AG09"}
set AGAstring to {"AGA", "AGB", "AGC", "AGD", "AGE", "AGF", "AGG", "AGH", "AGI", "AGJ", "AGK", "AGL", "AGM", "AGN", "AGO", "AGP", "AGQ", "AGR", "AGS", "AGT", "AGU", "AGV", "AGW", "AGX", "AGY", "AGZ"}
set AG_Astring to {"AG_A", "AG_B", "AG_C", "AG_D", "AG_E", "AG_F", "AG_G", "AG_H", "AG_I", "AG_J", "AG_K", "AG_L", "AG_M", "AG_N", "AG_O", "AG_P", "AG_Q", "AG_R", "AG_S", "AG_T", "AG_U", "AG_V", "AG_W", "AG_X", "AG_Y", "AG_Z"}
--BI Files
set BI0string to {"BI0", "BI1", "BI2", "BI3", "BI4", "BI5"}
set BI6string to {"BI6"}
set BI7string to {"BI7"}
set BI8string to {"BI8"}
set BI9string to {"BI9"}
set BIAstring to {"BIA", "BIB", "BIC", "BID", "BIE", "BIF", "BIG", "BIH", "BII", "BIJ", "BIK", "BIL", "BIM", "BIN", "BIO", "BIP", "BIQ", "BIR", "BIS", "BIT", "BIU", "BIV", "BIW", "BIX", "BIY", "BIZ"}
set BI_Astring to {"BI_A", "BI_B", "BI_C", "BI_D", "BI_E", "BI_F", "BI_G", "BI_H", "BI_I", "BI_J", "BI_K", "BI_L", "BI_M", "BI_N", "BI_O", "BI_P", "BI_Q", "BI_R", "BI_S", "BI_T", "BI_U", "BI_V", "BI_W", "BI_X", "BI_Y", "BI_Z"}
--MOVING THE ACTUAL FILES TO THE 1_4C IMAGES FOLDERS
--Moving AG files to 1_4c IMAGES Folders
if AG00string contains (text 1 thru 4 of fileToMove_Name) then
move fileToMove to alias "Volumes:server1:Advertising Department:2_IMAGES - HIGH RES FOR PRINT:1_4c IMAGES:AG-high res images:AG00 - AG03 - HI RES:"
else if AG04string contains (text 1 thru 4 of fileToMove_Name) then
move fileToMove to alias "Volumes:server1:Advertising Department:2_IMAGES - HIGH RES FOR PRINT:1_4c IMAGES:AG-high res images:AG04 - AG09 - HI RES:"
else if AGAstring contains (text 1 thru 3 of fileToMove_Name) then
move fileToMove to alias "Volumes:server1:Advertising Department:2_IMAGES - HIGH RES FOR PRINT:1_4c IMAGES:AG-high res images:AGA - AGZ - HI RES:"
else if AG_Astring contains (text 1 thru 4 of fileToMove_Name) then
move fileToMove to alias "Volumes:server1:Advertising Department:2_IMAGES - HIGH RES FOR PRINT:1_4c IMAGES:AG-high res images:AGA - AGZ - HI RES:"
--Moving BI files to 1_4c IMAGES Folders
else if BI0string contains (text 1 thru 3 of fileToMove_Name) then
move fileToMove to alias "Volumes:server1:Advertising Department:2_IMAGES - HIGH RES FOR PRINT:1_4c IMAGES:BI-high res images:BI0 - BI5 - HI RES:"
else if BI6string contains (text 1 thru 3 of fileToMove_Name) then
move fileToMove to alias "Volumes:server1:Advertising Department:2_IMAGES - HIGH RES FOR PRINT:1_4c IMAGES:BI-high res images:BI6 - HI RES:"
else if BI7string contains (text 1 thru 3 of fileToMove_Name) then
move fileToMove to alias "Volumes:server1:Advertising Department:2_IMAGES - HIGH RES FOR PRINT:1_4c IMAGES:BI-high res images:BI7 - HI RES:"
else if BI8string contains (text 1 thru 3 of fileToMove_Name) then
move fileToMove to alias "Volumes:server1:Advertising Department:2_IMAGES - HIGH RES FOR PRINT:1_4c IMAGES:BI-high res images:BI8 - HI RES:"
else if BI9string contains (text 1 thru 3 of fileToMove_Name) then
move fileToMove to alias "Volumes:server1:Advertising Department:2_IMAGES - HIGH RES FOR PRINT:1_4c IMAGES:BI-high res images:BI9 - HI RES:"
else if BIAstring contains (text 1 thru 3 of fileToMove_Name) then
move fileToMove to alias "Volumes:server1:Advertising Department:2_IMAGES - HIGH RES FOR PRINT:1_4c IMAGES:BI-high res images:BIA - BIZ - HI RES:"
else if BI_Astring contains (text 1 thru 4 of fileToMove_Name) then
move fileToMove to alias "Volumes:server1:Advertising Department:2_IMAGES - HIGH RES FOR PRINT:1_4c IMAGES:BI-high res images:BIA - BIZ - HI RES:"
--Moving All Other Files to the "File Manually in 1_4c IMAGES" Folder inside the Processing Folder
else
move fileToMove to alias "Volumes:server1:Advertising Department:5_ADVERTISING DEPT - PREPRESS:1_ADV IMAGE PROCESSING:2_PROCESSING:Processing:Scripts:File Manually in 1_4c IMAGES:"
end if
--Moving Files to the "File Manually in 1_4c IMAGES" Folder inside the Processing Folder if there is an error
on error
move fileToMove to alias "Volumes:server1:Advertising Department:5_ADVERTISING DEPT - PREPRESS:1_ADV IMAGE PROCESSING:2_PROCESSING:Processing:Scripts:File Manually in 1_4c IMAGES:"
end try
end tell
end repeat
end open