Help in a renaming routine

Hello,

I am writing a script to do the following:

-To process a CD full of images, some loose and some within folders
-rename each image using the name of the folder that contains it
-make sure all the images are jpegs, change any that are not into jpegs
-duplicate the image and make a low res and a high res version and save in separate folders
-then I want use the image name and preview as elements of a FM database

The attached script seems like a good start, but when it get’s to the repeat to rename folders I get this message,

“Can’t set name of "FAT003EN.jpg" to "test_folder a1.jpg".”

Any help would be greatly appreciated. Thanks for your time.

Here is my script so far:


property type_list : {"TIFF", "JPEG", "PNGf", "PICT"}
property extension_list : {"tif", "tiff", "jpg", "jpeg", "png", "pict", "pct"}


--separate folders from other loose files, add to list sub_folders
global sourcefolder
set sourcefolder to "Macintosh HD:Users:iMac_G5:Desktop:asource_folder:"
set infofile to (info for file "Macintosh HD:Users:iMac_G5:Desktop:asource_folder:")

global holding_folder
set holding_folder to "Macintosh HD:Users:iMac_G5:Desktop:aholding_folder:"

global sub_folders
set sub_folders to {}
set filelist to list folder sourcefolder without invisibles



repeat with i from 1 to number of items in filelist
	set this_item to item i of filelist
	set inforec to info for file (sourcefolder & this_item)
	
	
	if (kind of inforec) is "folder" then set end of sub_folders to (name of inforec)
	
	
end repeat
end

if exists items in sub_folders then renamestuff()

on renamestuff()
	tell application "Finder"
		repeat with afolder in sub_folders
			set listsub to list folder of (sourcefolder & afolder) without invisibles
			set infoname to info for file (sourcefolder & afolder)
			set newname to name of infoname as string
			
			
			set name_increment to 1
			
			repeat with i from 1 to number of items in listsub
				set this_item to item i of listsub
				set name of this_item to (the newname & name_increment & "." & "jpg"as string)
				
				set the name_increment to the name_increment + 1
			end repeat
			
		end repeat
	end tell
	
end renamestuff

This looks like an OS X problem - moved to that forum.

I had the same problem recently. AppleScript returns the names of file system objects as string values, when what you (and at the time, I) need is a list of aliases. Bruce was kind enough to provide details (Rename home directories).

Once you define your ‘root’ folder, you can do that like this:

set sourceFolder to "Macintosh HD:Picture_CD"
set folderList to folders of (result as alias) as alias list

Hi there,

thanks for you reply, but I tried that bit of code and script editor tells me “expected end of line but found class instead” If you think of anything else I happy to hear since I can’t figure it out.

thanks again,
Jamie

picturedude, the code that ecwade mentioned must be inside a Finder tell block.