Problem with OS9 script in OSX

I have an Applescript (below) that I always used in OS 9. Now that I have OS X I want to run the same script. I opened it in the Script Editor and compiled but when I try to run the script I get an error, “Expected a reference.” This occurs at “repeat with j from 1 to the number of folders in masterFolder”. I don’t know what it means. The old editor had a Syntax checker that caught this kind of thing but nothing like that in OS X that I can find.

Is there a converter script or anything like that around? Do I have to start learnig AS from rock bottom (which is not far from where I am anyway)?

Thanks

tell application “Finder”
repeat
set masterFolder to choose folder
set Tester to name of masterFolder as text
if Tester contains “photo” then exit repeat
set thisDialog to display dialog “Folder name must contain ‘Photo’!”
end repeat
end tell
tell application “Finder”
with timeout of 500 seconds
repeat with j from 1 to the number of folders in masterFolder
set x to folder j of masterFolder
set folderName to characters 1 thru -1 of (name of x as text) – remove colon
repeat with i from 1 to the number of files in x
set oldFileName to name of file i of x
set newFilename to (folderName & “-” & oldFileName) as text
set the name of file i of x to newFilename
end repeat
end repeat
end timeout
display dialog " Done." buttons (“OK”) default button “OK”
end tell

Hi,

I copied the text of your script straight from your post and pasted into the script editor. It compiled ok and at a quick glance it looks like it should work. Maybe you should do the same.

gl,

That’s what I did and it returned the same error on two machines. It stops on the word “number”. I must be doing something wrong, but what?

Here is a simplified version of the script that works:

tell application "Finder"
	repeat
		set masterFolder to (choose folder with prompt "Select Photo Folder:") as alias
		if name of masterFolder contains "photo" then exit repeat
		set thisDialog to display dialog "Folder name must contain 'Photo'!"
	end repeat
	repeat with this_folder in (get folders of masterFolder)
		set folderName to name of this_folder
		repeat with this_file in (get files of this_folder)
			set oldFileName to name of this_file
			set name of this_file to (folderName & "-" & oldFileName)
		end repeat
	end repeat
	display dialog "Done." buttons ("OK") default button "OK"
end tell

Jon

Thanks. I’ll give it a try,

Worked great! Thanks again.