set file comment

Is there a shorter way to write this:

	
tell item the_image of item "dupsFolder" of item "OH" of application "Finder" to set comment to (the_name & return & (current date)) as string

After you define the file by selection or “hardwiring”


set the_image to choose file
--or as example
set the_image to "Diskname:Path:to:dupsFolder:Image.jpg"

then you can


tell application "Finder" to set comment of the_image to ((name of the_image) & return & (current date)) as string

Thanks!

Your suggestion works, however, the final path has a folder with a space in its name :slight_smile:
When I add a space to ‘dupsFolder’ so that it’s Path:EH:dups Folder:image.jpg, the script no longer works.

I tried using single quotes around the name
“Path:EH:‘dups Folder’:image.jpg”

Comments are not coming through.

Any suggestions welcomed

soda, sitcom’s script works fine for me. Would you post all the code you’re currently using.

Here it goes.
I’m getting the files from the ftp.


using terms from application "Mail"
	on perform mail action with messages theMessages
		repeat with thisMail in theMessages
			tell thisMail
				set the_subject to get subject
				set the_sender to get sender
				set the_body to (source of thisMail as text)
			end tell
			--display dialog the_body
		end repeat
		set the_info to the_body
		set AppleScript's text item delimiters to {"**"}
		set the_info to second text item of (the_info as string)
		set AppleScript's text item delimiters to {"|"}
		set the_name to first text item of (the_info as string)
		set the_email to second text item of (the_info as string)
		set the_image to third text item of (the_info as string)
		--display dialog the_name & " " & the_image
		download(the_image)
		comments(the_name, the_email, the_image)
	end perform mail action with messages
end using terms from
--
property ftp_server : "[url=http://www.host.com]www.host.com[/url]"
property ftp_path : "/host.com/uploaded_data/"
property ftp_username : "u_name"
property ftp_password : "p_word"
property ftp_file : ""
property the_recipient : "sandraqu@mailworks.org"
property the_recipient_name : "Sandra Qu"
property the_subject : "Incoming File"
--
on download(the_image)
	set ftp_file to the_image
	do shell script "ftp -o ~/Desktop/EH/'dups Folder'/" & ftp_file & " ftp://" & ftp_username & ":" & ftp_password & "@" & ftp_server & ftp_path & ftp_file
end download
--
on comments(the_name, the_email, the_image)
	display dialog the_image
	set the_filename to alias "Alaska:Users:sl:Desktop:EH:dups Folder:" & the_image
	--display dialog the_filename
	tell application "Finder" to set comment of the_filename to the_name & return & the_email & return & (current date) as string
	--tell item the_image of item "dupsFolder" of item "EH" of application "Finder" to set comment to (the_name & return & the_email & return & (current date)) as string
end comments

You should try changing this line.

set the_filename to alias "Alaska:Users:sl:Desktop:EH:dups Folder:" & the_image

to this:

set the_filename to ("Alaska:Users:sl:Desktop:EH:dups Folder:" & the_image) as alias

That will give you a valid alias. Your line is probably returning a list like this:
{alias “Alaska:Users:sl:Desktop:EH:dups Folder:”, the_image}

Thank you!