how to modify this script?

I found a script By Chris Barber which is very close to what I am trying to accomplish:

http://macscripter.net/viewtopic.php?pid=132545#p132545

the scripts inserts the same comment in the “Get Info” window to all files from a specific folder. Instead I need to put a different comment for each file located in my chosen folder. I need to insert the actual file name (not the path) without the extension.

I hope someone can help me to place the file name in the comment as a new comment till the end of the repeat

I will be very grateful to anyone who can help to modify the script.

Thanks

This is Chris Barber’s original:


tell application "Finder"
   activate
   
   try
       set thisFolder to (target of front Finder window) as alias
   on error
       choose folder with prompt "Set comments of files in this folder:"
       set thisFolder to result
   end try
   
   display dialog "Comment:" default answer "" with title "Set Spotlight Comments"
   set newComment to text returned of result
   
   display dialog "How to handle existing comments?" buttons {"Overwrite", "Cancel", "Append"} default button 3 with title "Set Spotlight Comments"
   
   if (button returned of result) is "Overwrite" then
       set comment of every file of folder thisFolder to newComment
   else
       get every file of folder thisFolder
       repeat with thisFile in result
           tell thisFile
               if length of (comment as text) is not 0 then
                   get ", " & newComment
               else
                   get newComment
               end if
               set comment to (comment & result)
           end tell
       end repeat
   end if
   
   beep
end tell

try this


set theFolder to choose folder
tell application "Finder"
	set theFiles to files of theFolder
	repeat with thisFile in theFiles
		set {name:Nm, name extension:Ex} to (info for thisFile as alias)
		set baseName to text 1 thru ((get offset of "." & Ex in Nm) - 1) of Nm
		tell thisFile
			if length of (comment as text) is not 0 then
				get return & baseName
			else
				get baseName
			end if
			set comment to (comment & result)
		end tell
	end repeat
	beep
end tell


Dear Stefan

i suppose you are not only a gentleman but also a very kind person.

Several times you gave supportive and great help.

I wish you all the best for this time and again for the previous times you gave me a hand.

While I am not particularly young, and unfortunately I don’t have your abilities with manuals and so on I often get into troubles in what I do.

However… as every single time you helped me out perhaps you will be interested in seeing how relevant was your help in what I do.

So if you like I will send you the links for these films which without your help couldn’t have happened, and please allow me to put your name in the credits

regards