Re: referencing the last item in a list
Re: referencing the last item in a list
- Subject: Re: referencing the last item in a list
- From: Emmanuel <email@hidden>
- Date: Tue, 16 Jul 2002 22:24:22 +0200
At 7:46 PM +0200 16/7/02, email@hidden wrote:
>
>
so to recap, i want to be able to move the files from one folder to
>
another and rename them beginning with the next number. can anyone help me
>
with this? thanks,
>
matthew
You did not say whether the prefix is the same for all files, or if you
have different prefixes. Assuming the first case, here is how you might
proceed:
1. List the contents of the folder. That's a job for "list folder" (check
the Standard Additions' dictionary). ("without invisibles" is usually a
good idea)
2. Sort the list returned. Various means to do that. Personally, I use
simply the "sort" routine of Smile (but you have to use Smile as your
script editor).
3. Build up the new name. If the structure of the name is "FOTO0021.jpg",
then the next name after theOldName will be:
--------------- untested
(character 1 thru 4 of theOldName) &
(1 + (character 5 thru 8 of theOldName)) &
(character 9 thru 12 of theOldName)
---------------
[writing "1 + " forces the coercion to integer, and concatenating with a
string forces the coercion back to string]
3. Rename the copied files. When you copy a file (you must use Finder)
Finder returns (or, should return - it has not always done so) a reference
to the new file. Ask Finder to rename it: tell app "Finder" to set name of
theNewFile to theNewName.
Emmanuel
_______________________________________________
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.