• 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
changing the name of a file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

changing the name of a file


  • Subject: changing the name of a file
  • From: Doug Tallman <email@hidden>
  • Date: Sat, 10 Oct 2009 00:48:02 -0400

I have a script that copies files from my download folder onto an external drive then deletes them from my work drive.

The guts of it look like this:

on run
tell application "Finder"
set fileList to the selection
repeat with fn in fileList
try
move fn to folder "Cupertino:Users:douglastallman:Documents:Downloads:" replacing ask
on error
set newName to my erred(fn)
set name of fn to newName
move fn to folder "Cupertino:Users:douglastallman:Documents:Downloads:" replacing ask
end try
move fn to trash
end repeat
end tell
end run


Sometimes, there's already a file on the destination drive with the same name, so when the script errors, I take the file name apart, add a date & time suffix and rename the file. But the move command now can't find the file.

In my script, fn is an alias and I was under the impression, falsely I guess, that because the name was a property, it could be changed and the alias still pointed to the same file. This script renames the file, then errors on anything that follows in the next line that calls fn.

What am I doing wrong?

doug

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: changing the name of a file
      • From: Axel Luttgens <email@hidden>
    • Re: changing the name of a file
      • From: Yvan KOENIG <email@hidden>
  • Prev by Date: Re: spurious timeout on nth Apple event on Snow Leopard
  • Next by Date: Addressing a cell in "Numbers"
  • Previous by thread: Re: how to suppress or ignore errors?
  • Next by thread: Re: changing the name of a file
  • Index(es):
    • Date
    • Thread