• 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: delete first 3 characters in a file name
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: truncate the hostname of local computer
  • Next by Date: Re: [OT] Re: Smile and FruitMenu
  • Previous by thread: Re: delete first 3 characters in a file name
  • Next by thread: RE: delete first 3 characters in a file name
  • Index(es):
    • Date
    • Thread