Can't append suffix to file name

I’m reworking the code from a Quicktime droplets I got from the Apple site. It’s called “Prep camera images for web”. It’s a great script, however, it doesn’t seem to add the “.jpg” to the end of the file. I put a line of code in (in red below) that I thought would do it, however, I end up with “.jpg.jpg” instead of just “.jpg”. Any ideas?

Here is the original code:

tell application “Finder”
–rename the image and move it to the desktop or other folder
set the new_name to (my add_extension(current_name))
set the name of the first file of the temp_folder whose name ends with “1.jpg” to the new_name
set this_image to move file new_name of the temp_folder to the destination_folder with replacing
– change the file type to open in Preview
set the creator type of this_image to “prvw”
– delete the temp folder and its contents
delete temp_folder
empty trash
end tell

Here is what I added:


tell application “Finder”
–rename the image and move it to the desktop or other folder
set the new_name to (my add_extension(current_name))
set the name of the first file of the temp_folder whose name ends with “1.jpg” to the new_name
set this_image to move file new_name of the temp_folder to the destination_folder with replacing
– change the file type to open in Preview
set the creator type of this_image to “prvw”
–delete the temp folder and its contents
set the name of the file new_name of the destination_folder to the new_name & “.jpg”[color=blue]
delete temp_folder
empty trash
end tell

[/color]

Are you sure the file extension isn’t just being hidden? If you’re ending up with two “.jpg” extensions then it is probably already there. Try this:

set extension hidden of (file new_name of destination_folder) to false

I tried putting that line in at the end, but had no luck with it. Still the same. It’s weird because when I put “display dialog new_name” in there, it gives me the name with the .jpg extension. Also, if i do a Get Info on the file, the “Hide Extension” box is not checked. If I check it, then do Get Info again and uncheck it, the .jpg extension suddenly appears.??? So it must be setting it, but for some reason it does not show even though the Hide Extension option is not checked. Also, when I drag the file to Safari, it displays the name with .jpg at the end.

So with that info, I changed the end of the script to this:


set extension hidden of (file new_name of destination_folder) to true
delete temp_folder
set extension hidden of (file new_name of destination_folder) to false
empty trash
end tell

Seems like a real kludge, but hey it worked!

Thanks for the help, redsweater!