script not working since move to 10.4

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

Hi,

You know about where the trou ble is occuring, so just make a simple script to find exactly what is wrong. Here’s a short script that should work in the script editor:

set ext_list to {“pdf”}
set folder_ref to (choose folder) – alias reference
tell application “Finder”
get name of every file of folder folder_ref whose name extension is in ext_list
end tell

It might be the filter:

whose name extension is in ext_list

because here in Jaguar it didn’t work and was miraculously fixed through some update. it might be the reference:

folder folder_ref

because folder_ref is already a reference and the leading ‘folder’ is not necessary. Although I doubt that your system is having trouble coercing it to a proper reference.

Anyway, if it’s the filter then you can use:

whose name extension is “pdf”

instead of the ‘contained by’ operator. If more than on extension is needed then use the boolean ‘or’:

whose name extension is "pdf’ or name extension is "qdf’ …

gl,

Like realizing the reason the script isn’t working is simply because I named the harddrive with an extra " " at the end, and so the references didn’t work. Ugh :slight_smile: Thanks for the tips though!

Glad you got it working.

It’s strange though, because it should have errored on the line before when coercing to alias:

set tSourceFolder to alias “Macintosh HD :Users:phil:Desktop:Magic:Start Here:”

gl,