Page 1 of 1

changing file name

Posted: Wed Jul 14, 2010 5:15 pm
by dhobbs
Hi, I have an image control that I load from a file on disk. I would like to change the name of the image, and have it change the name of the file on disk. Is there an easy way to do this?
Thanks,

--Doug

Re: changing file name

Posted: Wed Jul 14, 2010 6:06 pm
by Klaus
Hi Doug,

you can:

Code: Select all

...
set the name of img "Old name of your image" to "New name of your image"
...
To rename an image inside of your stack.

Use the "rename" command to rename the image (or any file) on disk:

Code: Select all

...
rename file "/Users/klaus/Desktop/jigsawtest.jpg" to "/Users/klaus/Desktop/a completetely new name.jpg"
...
Best

Klaus

Re: changing file name

Posted: Mon Jul 19, 2010 2:28 pm
by dhobbs
Thanks Klaus,
Works great. My rename code now looks like:

Code: Select all

on mouseUp
   put the fileName of image "image" into tOldName
   set itemDelimiter to "."
   put tOldName into tNewName
   ask "New Name:"
   put it into item 1 of tNewName
   rename file tOldName to (defaultFolder & "\" & tNewName)
   send "openstack" to stack "ImageBrowser"  ##refresh list of file names
end mouseUp
Just thought I'd post this in case anyone else wants a snippet to do a similar thing.

Thanks again,

--Doug