Script not working?

I made a little clean-up script a while ago, but it dosen’t seem to work on my 10.5.8 machine. Any idea why?

property image_extension_list : {"tif", "tiff", "gif", "png", "pict", "pct", "jpg", "jpeg", "bmp", "psd"}
property video_extension_list : {"avi", "mov", "mpg", "mpeg", "wmv"}
property audio_extension_list : {"mp3", "wav", "mp4", "aac", "m4a", "m4b", "ogg", "midi", "flp"}
property archive_extension_list : {"zip", "sit", "tar", "tgz", "gz", "bzip2", "rar"}
property documents_extension_list : {"doc", "pdf", "txt", "xls", "ppt", "pages", "rtf"}
property application_extension_list : {"dmg", "hqx", "toast", "app"}

property image_foldername : "Images"
property video_foldername : "Video"
property audio_foldername : "Audio"
property archive_foldername : "Archives"
property documents_foldername : "Documents"
property application_foldername : "Applications"


on adding folder items to this_folder after receiving added_items
	
	repeat with this_item in added_items
		tell application "Finder"
			
			if (the name extension of the this_item is in the image_extension_list) then
				my makeamove(this_item, this_folder, image_foldername)
			end if
			
			if (the name extension of the this_item is in the video_extension_list) then
				my makeamove(this_item, this_folder, video_foldername)
			end if
			
			if (the name extension of the this_item is in the audio_extension_list) then
				my makeamove(this_item, this_folder, audio_foldername)
			end if
			
			if (the name extension of the this_item is in the archive_extension_list) then
				my makeamove(this_item, this_folder, archive_foldername)
			end if
			
			if (the name extension of the this_item is in the documents_extension_list) then
				my makeamove(this_item, this_folder, documents_foldername)
			end if
			
			if (the name extension of the this_item is in the application_extension_list) then
				my makeamove(this_item, this_folder, application_foldername)
			end if
			
		end tell
	end repeat
end adding folder items to

on makeamove(this_item, root_folder, target_foldername)
	
	tell application "Finder"
		
		if not (exists folder target_foldername of root_folder) then
			make new folder at root_folder with properties {name:target_foldername}
		end if
		
		set the target_folder to folder target_foldername of root_folder
		my resolve_conflicts(this_item, root_folder, target_folder)
		move file this_item to the target_folder
		
	end tell
	
end makeamove

on resolve_conflicts(this_item, root_folder, target_folder) --renames the item if dublicate exists in target folder
	
	tell application "Finder"
		
		set file_extension to the name extension of this_item
		set the file_name to the name of this_item
		
		if the file_extension is "" then
			set the trimmed_name to the file_name
		else
			set the trimmed_name to text 1 thru -((length of file_extension) + 2) of the file_name
		end if
		
		if (exists document file file_name of target_folder) then
			
			set the name_increment to 1
			
			repeat
				set the new_name to (the trimmed_name & "_" & (name_increment as string) & "." & file_extension) as string
				
				if not (exists document file new_name of the target_folder) then
					
					set the name of document file file_name of folder root_folder to the new_name
					exit repeat
				else
					
					set the name_increment to the name_increment + 1
					
				end if
			end repeat
		end if
	end tell
	
	return the file_name
	
end resolve_conflicts

Model: iMac 2007
AppleScript: idk
Browser: Safari 534.10
Operating System: Mac OS X (10.5)

Hi,

I guess the crucial line is


move file this_item to the target_folder

this_item is an alias specifier, so omit the keyword file

the folder action event handler can be simplified a bit, the Finder is not needed


on adding folder items to this_folder after receiving added_items
	
	repeat with this_item in added_items
		set nameExtension to name extension of (info for this_item)
		
		if (nameExtension is in image_extension_list) then
			makeamove(this_item, this_folder, image_foldername)
			
		else if (nameExtension is in video_extension_list) then
			makeamove(this_item, this_folder, video_foldername)
			
		else if (nameExtension is in audio_extension_list) then
			makeamove(this_item, this_folder, audio_foldername)
		
		else if (nameExtension is in archive_extension_list) then
			makeamove(this_item, this_folder, archive_foldername)
			
		else if (nameExtension is in documents_extension_list) then
			makeamove(this_item, this_folder, documents_foldername)
			
		else if (nameExtension is in application_extension_list) then
			makeamove(this_item, this_folder, application_foldername)
		end if
		
	end repeat
end adding folder items to

So wait. Slightly confused. Would i put your non-finder code instead of

on makeamove(this_item, root_folder, target_foldername)
	
	tell application "Finder"
		
		if not (exists folder target_foldername of root_folder) then
			make new folder at root_folder with properties {name:target_foldername}
		end if
		
		set the target_folder to folder target_foldername of root_folder
		my resolve_conflicts(this_item, root_folder, target_folder)
		move this_item to the target_folder
		
	end tell
	
end makeamove

?
Or instead of

on resolve_conflicts(this_item, root_folder, target_folder) --renames the item if dublicate exists in target folder
	
	tell application "Finder"
		
		set file_extension to the name extension of this_item
		set the file_name to the name of this_item
		
		if the file_extension is "" then
			set the trimmed_name to the file_name
		else
			set the trimmed_name to text 1 thru -((length of file_extension) + 2) of the file_name
		end if
		
		if (exists document file file_name of target_folder) then
			
			set the name_increment to 1
			
			repeat
				set the new_name to (the trimmed_name & "_" & (name_increment as string) & "." & file_extension) as string
				
				if not (exists document file new_name of the target_folder) then
					
					set the name of document file file_name of folder root_folder to the new_name
					exit repeat
				else
					
					set the name_increment to the name_increment + 1
					
				end if
			end repeat
		end if
	end tell
	
	return the file_name
	
end resolve_conflicts

?
Thanks,
Ari

it replaces the on adding folder items handler

So the script should go like this?

property image_extension_list : {"tif", "tiff", "gif", "png", "pict", "pct", "jpg", "jpeg", "bmp", "psd"}
property video_extension_list : {"avi", "mov", "mpg", "mpeg", "wmv"}
property audio_extension_list : {"mp3", "wav", "mp4", "aac", "m4a", "m4b", "ogg", "midi", "flp"}
property archive_extension_list : {"zip", "sit", "tar", "tgz", "gz", "bzip2", "rar"}
property documents_extension_list : {"doc", "pdf", "txt", "xls", "ppt", "pages", "rtf"}
property application_extension_list : {"dmg", "hqx", "toast", "app"}

property image_foldername : "Images"
property video_foldername : "Video"
property audio_foldername : "Audio"
property archive_foldername : "Archives"
property documents_foldername : "Documents"
property application_foldername : "Applications"


on adding folder items to this_folder after receiving added_items
	
	repeat with this_item in added_items
		set nameExtension to name extension of (info for this_item)
		
		if (nameExtension is in image_extension_list) then
			makeamove(this_item, this_folder, image_foldername)
			
		else if (nameExtension is in video_extension_list) then
			makeamove(this_item, this_folder, video_foldername)
			
		else if (nameExtension is in audio_extension_list) then
			makeamove(this_item, this_folder, audio_foldername)
			
		else if (nameExtension is in archive_extension_list) then
			makeamove(this_item, this_folder, archive_foldername)
			
		else if (nameExtension is in documents_extension_list) then
			makeamove(this_item, this_folder, documents_foldername)
			
		else if (nameExtension is in application_extension_list) then
			makeamove(this_item, this_folder, application_foldername)
		end if
		
	end repeat
end adding folder items to
on makeamove(this_item, root_folder, target_foldername)
	
	tell application "Finder"
		
		if not (exists folder target_foldername of root_folder) then
			make new folder at root_folder with properties {name:target_foldername}
		end if
		
		set the target_folder to folder target_foldername of root_folder
		my resolve_conflicts(this_item, root_folder, target_folder)
		move this_item to the target_folder
		
	end tell
	
end makeamove

on resolve_conflicts(this_item, root_folder, target_folder) --renames the item if dublicate exists in target folder
	
	tell application "Finder"
		
		set file_extension to the name extension of this_item
		set the file_name to the name of this_item
		
		if the file_extension is "" then
			set the trimmed_name to the file_name
		else
			set the trimmed_name to text 1 thru -((length of file_extension) + 2) of the file_name
		end if
		
		if (exists document file_name of target_folder) then
			
			set the name_increment to 1
			
			repeat
				set the new_name to (the trimmed_name & "_" & (name_increment as string) & "." & file_extension) as string
				
				if not (exists document new_name of the target_folder) then
					
					set the name of document file_name of folder root_folder to the new_name
					exit repeat
				else
					
					set the name_increment to the name_increment + 1
					
				end if
			end repeat
		end if
	end tell
	
	return the file_name
	
end resolve_conflicts

?
Sorry i’m such a noob :stuck_out_tongue: Correct the code if i’m wrong.

Yes