Greetings! I am a sometime Applescript user, but not a programmer. I need to copy pdfs from one folder into their appropriate folders and replace older files of the same name. Our pdfs have numerical names to keep them in order, but with letters to designate book names. Thus folderX will have files such as
1234-A.pdf
1234-B.pdf
1234-C.pdf
5678-A.pdf
5678-D.pdf
and so on.
So basically, everything I drop in folderX, I would like applescript to copy files with "A" on to folder A, files with "B" on to folder B, and on and on. All of these are in "mainfolder".
The exception are files with "Q", which I want to copy to every folder in "mainfolder".
Here is what I came up with from other scripts, but I get the message "Can't make every folder of alias "me-DT:Users:me
esktop:folderX" into type folder. -1700"
What's going wrong?
1234-A.pdf
1234-B.pdf
1234-C.pdf
5678-A.pdf
5678-D.pdf
and so on.
So basically, everything I drop in folderX, I would like applescript to copy files with "A" on to folder A, files with "B" on to folder B, and on and on. All of these are in "mainfolder".
The exception are files with "Q", which I want to copy to every folder in "mainfolder".
Here is what I came up with from other scripts, but I get the message "Can't make every folder of alias "me-DT:Users:me
What's going wrong?
Code:
set sourceFolder to alias "me-DT:Users:me:Desktop:folderX"
set destinationFolder to alias "me-DT:Users:me:Desktop:mainfolder"
tell application "Finder"
set theFiles to every file in sourceFolder as list
repeat with aFile in theFiles
set fileName to name of aFile as text
try
if fileName contains "A" then
move aFile to destinationFolder:A with replacing
else if fileName contains "B" then
move aFile to destinationFolder:B with replacing
else if fileName contains "C" then
move aFile to destinationFolder:C with replacing
else if fileName contains "D" then
move aFile to destinationFolder:D with replacing
else if fileName contains "Q" then
move aFile to (every folder in destinationFolder) with replacing
end if
delay 1
on error errorMessage number errorNumber
display alert errorMessage & space & errorNumber message ¬
"An error occured while trying to move the file " & aFile & "." & return & ¬
"Check the file exists, or the delay time setting." as warning giving up after 60
end try
end repeat
end tell
Last edited by a moderator: