• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Rename File Script newbie question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Rename File Script newbie question (From: Phil Holden <email@hidden>)

  • Prev by Date: Re: Selection (was Re: Better Open Dictionary)
  • Next by Date: Re: Script to insert SE2 script in Eudora message
  • Previous by thread: Re: Rename File Script newbie question
  • Next by thread: Re: Rename File Script newbie question
  • Index(es):
    • Date
    • Thread