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:54:22 +0000
- Mac-eudora-version: 6.0a9
At 5:20 pm +0000 6/3/03, Phil Holden wrote:
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.
A simpler way than the last I suggested to do this is to use the UNIX
mv (move with replacing) command.
The only significant line in this script is the last one; the rest is
UI display. Because we're using the shell, the Finder won't update
immediately, so you'll have to kick the window to get XXXXX.txt to
disappear.
set _folder to "" & (path to current user folder)
set _oldname to "XXXXX.txt"
set _newname to "YYYYY.txt"
open for access file (_folder & _oldname)
close access file (_folder & _oldname)
set _fileToMove to quoted form of POSIX path of (_folder & _oldname)
set _fileToDelete to quoted form of POSIX path of (_folder & _newname)
tell application "Finder"
activate
reveal file (_folder & _oldname)
end tell
do shell script "mv" & space & _fileToMove & space & _fileToDelete
_______________________________________________
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.