I’ve got a script I use multiple times a day, and now it is not functioning properly.
The trouble line seems to be this:
set tempList to (the name of every file of folder tStartHereFolder whose name ends with “.pdf”)
It results in an error that says "Finder got an error: Can’t get name of every file of folder tStartHereFolder whose name ends with “.pdf”.
If looked to make sure that tStartHereFolder is defined, and it is. Not sure if something has changed in applescript…
here is the entire script should it help…
property pdfFiles : {“pdf”}
property moduleList : {}
tell application “Finder”
activate
set tStartHereFolder to (“Macintosh HD:Users:phil:Desktop:Magic:Start Here:”)
set tStep2Folder to (“Macintosh HD:Users:phil:Desktop:Magic:Start Here:Step 2:”)
set tStep3Folder to (“Macintosh HD:Users:phil:Desktop:Magic:Start Here:Step 3:”)
set tempList to (the name of every file of folder tStartHereFolder whose name ends with “.pdf”)
set moduleList to {}
repeat with i in tempList
set z to word 1 of i
set moduleList to moduleList & z
end repeat
my MoveItemsToTrash(tStep2Folder, tStep3Folder)
my ShowMeTheMoney(tStep2Folder, tStep3Folder)
my MoveItemsToFolders(tStep2Folder, tStep3Folder)
open (“Macintosh HD:Users:phil:Documents:Applescript:Scripts:ChangeTheNames.app”) --this changes the file names to the 000.pdf format
end tell
on MoveItemsToTrash(tStep2Folder, tStep3Folder) --sends any file that begins with TRASH to the trash.
tell application “Finder”
select (every file of folder tStep2Folder whose name starts with “TRASH”)
if the selection ? {“Step 2”} then
try
move the selection to the trash
end try
end if
end tell
end MoveItemsToTrash
on ShowMeTheMoney(tStep2Folder, tStep3Folder)
tell application “Finder”
set tSourceFolder to alias “Macintosh HD :Users:phil:Desktop:Magic:Start Here:”
set nFileList to (the name of every file of folder tSourceFolder whose name extension is in pdfFiles)
set pFileList to {}
repeat with y in nFileList
set newName to word 1 of y
set pFileList to pFileList & newName
end repeat
return pFileList
end tell
end ShowMeTheMoney
on MoveItemsToFolders(tStep2Folder, tStep3Folder) --creates a new folder for each module number, then moves the files to their respective folder
tell application “Finder”
repeat with x in moduleList
make new folder at tStep3Folder with properties {name:x}
make new folder at tStep3Folder with properties {name:“IMAGES”}
–display dialog z
select (every file of folder tStep2Folder whose name starts with x)
–if the selection ? {} then
–try
move the selection to folder (tStep3Folder & “IMAGES”) --(“Macintosh HD:Users:phil:Desktop:Magic:Start Here:Step 3:06”)
select (every folder of folder tStep3Folder whose name is “IMAGES”)
move the selection to folder (tStep3Folder & x)
–display dialog x
–end try
–else
–nothing
–end if
end repeat
end tell
end MoveItemsToFolders