A little help needed - please?

Hello,
as you can probably tell from the script below I am new to Applescript (I used to ‘Record’ and edit scripts under OS7 to OS8 though). My main problem is when I try to move files simply from one folder to another (using OS 10.2.8 ), everything else seems to be working fine.

Secondly, I wonder if there is a way to lessen the amount of script by putting the repeated commands in a ‘function’ that can be used again and again.

Hope there is someone out there willing to help. Thank you for your time.

Well, here’s my script so far – cumbersome I know! Problem lines are in RED


on adding folder items to this_folder after receiving fileList

set theNewName to (do shell script "date  +%Y-%m-%d_%H-%M")

set toDesk to path to desktop as text
set doneFolder to toDesk & "mm_done:" as text
set processFolder to toDesk & "mm_process:" as text

repeat with i in fileList
	
	tell application "Finder" to set thisFileType to the file type of i
	
	say thisFileType
	
	if thisFileType is "JPEG" then
		do shell script "chmod 766 " & quoted form of POSIX path of i
		
		set theNewName to theNewName & ".jpg"
		tell application "Finder" to set name of i to theNewName
		
		[b][color=red]move the file theNewName to doneFolder[/color][/b]
		
	else if thisFileType is "TEXT" then
		do shell script "chmod 766 " & quoted form of POSIX path of i
		
		set theNewName to theNewName & ".txt"
		tell application "Finder" to set name of i to theNewName
		
		[b][color=red]move the file theNewName to doneFolder[/color][/b]
		
	else
		-- I'll think about this bit later!
		
		say "oops!"

	end if
end repeat
say "done"

end adding folder items to


Does this work?

on adding folder items to this_folder after receiving fileList
	
	set theNewName to (do shell script "date  +%Y-%m-%d_%H-%M")
	
	set toDesk to path to desktop as text
	set doneFolder to toDesk & "mm_done:" as text
	set processFolder to toDesk & "mm_process:" as text
	
	repeat with i in fileList
		
		tell application "Finder" to set thisFileType to the file type of i
		
		say thisFileType
		
		if thisFileType is "JPEG" then
			do shell script "chmod 766 " & quoted form of POSIX path of i
			
			set theNewName to theNewName & ".jpg"
			
			tell application "Finder"
				set name of i to theNewName
				move file theNewName of this_folder to folder doneFolder
			end tell
			
		else if thisFileType is "TEXT" then
			do shell script "chmod 766 " & quoted form of POSIX path of i
			
			set theNewName to theNewName & ".txt"
			
			tell application "Finder"
				set name of i to theNewName
				move the file theNewName of this_folder to folder doneFolder
			end tell
		else
			-- I'll think about this bit later! 
			
			say "oops!"
			
		end if
	end repeat
	say "done"
	
end adding folder items to

– Rob

Hello Rob,
sorry but your script doesn’t work. Not even the files get renamed. Thanks for your time though.
Chris

Hi again Rob,

it’s working!

I used this…
tell application “Finder” to set name of i to theNewName
tell application “Finder” to move the file theNewName of this_folder to folder doneFolder

which is your move script idea but with the tell app… on the same line and no end tell

Thanks again! :lol: