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

Re: changing the name of a file


  • Subject: Re: changing the name of a file
  • From: Axel Luttgens <email@hidden>
  • Date: Sat, 10 Oct 2009 14:03:24 +0200

Le 10 oct. 2009 à 06:48, Doug Tallman a écrit :

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

Hello Doug,

No, fn is a Finder reference (file "filename" of folder "foldername" of...).
I guess the easiest fix would be to ask the Finder to buil a list of aliases instead of a list of references:


	set fileList to the selection as alias list

HTH,
Axel _______________________________________________
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: Doug Tallman <email@hidden>
References: 
 >changing the name of a file (From: Doug Tallman <email@hidden>)

  • Prev by Date: Re: changing the name of a file
  • Next by Date: Re: changing the name of a file
  • Previous by thread: Re: changing the name of a file
  • Next by thread: Re: changing the name of a file
  • Index(es):
    • Date
    • Thread