Re: Rename File Script newbie question
Re: Rename File Script newbie question
- Subject: Re: Rename File Script newbie question
- From: John Delacour <email@hidden>
- Date: Thu, 6 Mar 2003 21:17:45 +0000
- Mac-eudora-version: 6.0a9
At 5:20 pm +0000 6/3/03, Phil Holden wrote:
tell application "Finder"
activate
move item"myfile" of folder "myfolder" to trash
set name of item "exportfilename" of folder "myfolder" to "newfilename"
end tell
This works OK but as I am testing my application the trash gets more
and more full. I know that I could empty the trash from my script
but I prefer not to do this.
Is there some way for me to rename a file to another name and if
this name already exists for this file to be overwritten. I have
read about using replacing boolean but can't seem to get this to
work in this script. I think that I need guidance on the exact
syntax for use of replacing.
I'm working in OS 10.2.4 but would like the script to work in OS9
and previous.
If you use the shell command rm (remove), you get nothing in the
trash. You can wathc a file being created and renamed here:
set _folder to "" & (path to current user folder)
set _oldname to "XXXXX.txt"
open for access file (_folder & _oldname)
close access file (_folder & _oldname)
tell application "Finder"
activate
reveal file (_folder & _oldname)
set _newname to "YYYYY.txt"
set _newpath to _folder & _newname
set _UNIXpath to POSIX path of _newpath
if exists file (_folder & _newname) then
do shell script "rm " & _UNIXpath
end if
delay 3
set name of file (_folder & _oldname) to _newname
end tell
JD
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.