Re: delete first 3 characters in a file name
Re: delete first 3 characters in a file name
- Subject: Re: delete first 3 characters in a file name
- From: kai <email@hidden>
- Date: Fri, 10 Dec 2004 01:48:07 +0000
On Thu, 9 Dec 2004 15:54:28 -0700, Michelle Steiner wrote:
On Dec 9, 2004, at 3:44 PM, kai wrote:
When it is supposed to change item 2, it changes item 3, so when it
tries to change item 3, it errors because the name doesn't have the
underscore.
The sequence of files can change as filenames are changed:
I see. In this case, then, it probably would have been better to use
the "repeat with a in b" syntax.
I personally prefer it in this kind of situation, mainly because it
seems a bit more straightforward to a simple country boy like me.
(There shouldn't normally be a problem with this syntax as long as one
remembers that 'a' is actually a reference.)
If a running count is required, then the "repeat with n from 1 to x"
syntax should still be possible - if a little more convoluted. The
trick is really to get the list of files first - since the Finder can't
subsequently change the order of that:
-------------------------------
set text item delimiters to "_"
tell application "Finder"
set fList to files of (choose folder)
repeat with n from 1 to count fList
set name of fList's item n to text item -1 of ¬
(get name of fList's item n)
end repeat
end tell
set text item delimiters to ""
-------------------------------
or
-------------------------------
set text item delimiters to "_"
tell application "Finder" to tell (get files of (choose folder)) to
repeat with n from 1 to count
set item n's name to text item -1 of (get item n's name)
end repeat
set text item delimiters to ""
-------------------------------
---
kai
_______________________________________________
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