• 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: Folder action to rename files
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Folder action to rename files


  • Subject: Re: Folder action to rename files
  • From: Matt Neuburg <email@hidden>
  • Date: Wed, 24 Aug 2005 10:28:46 -0700

On Wed, 24 Aug 2005 13:20:23 +0100, pete boardman <email@hidden>
said:
>I'm having trouble with this folder action, which is supposed to add
>a date stamp to a file's name when added to a folder. It seems to
>repeat the renaming action on the same file each time when I add a
>bunch of files. Can anyone point out my error?

I didn't bother to read your code, but let me point out that this problem is
specifically addressed in my book. As you cycle thru files renaming them,
you are changing the very thing you are cycling thru, so the way you are
pointing at those files can break down. For instance, item 3 of folder
"whatever" depends on that file's name in alphabetical order. If you change
that, your script can go haywire.

A simple and obvious solution is to start by gathering the ids of all the
items you intend to operate on. Now use only those ids to refer to the files
(i.e. cycle thru the list of ids WRT the folder so that everything remains
constant, not a list of files where you don't know what might happen).

m.

--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide
<http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt>



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: Select Finder items by Regular Expression
  • Next by Date: Re: lauch script via keyboard shortcut
  • Previous by thread: Re: Folder action to rename files
  • Next by thread: lauch script via keyboard shortcut
  • Index(es):
    • Date
    • Thread