• 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: Find/replace
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Find/replace


  • Subject: Re: Find/replace
  • From: Christopher Stone <email@hidden>
  • Date: Wed, 19 Aug 2009 06:03:47 -0500

Hey Bob,

On Aug 18, 2009, at 17:52, Robert Poland wrote:
I am trying to do a script that will strip the leading 5 characters from file names.
For example I want "0050_2010_winners_accessories" to become "2010_winners_accessories".

Applescript only (simplest and lightning quick):

set x to "1234567890"
text 6 thru -1 of x


Satimage Osax (very quick and versatile - my preferred means of find/replace):

-- All characters after the fifth one:
set x to "0050_2010_winners_accessories"

set findData to x
set findString to ".{5}(.+)"
set returnString to "\\1"

set theResult to ¬
find text findString ¬
in findData ¬
case sensitive false ¬
regexp true ¬
using returnString ¬
with string result


-- Using the first underscore as an anchor:

set x to "0050_2010_winners_accessories"

set findData to x
set findString to "_(.+)"
set returnString to "\\1"

set theResult to ¬
find text findString ¬
in findData ¬
case sensitive false ¬
regexp true ¬
using returnString ¬
with string result


Chris
 _______________________________________________
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

References: 
 >Find/replace (From: Robert Poland <email@hidden>)

  • Prev by Date: Re: Value of insertion point in Quark 8
  • Next by Date: Re: Unable to send user input string to Webster Dictionary Application using variable
  • Previous by thread: Re: Find/replace
  • Next by thread: Re: Find/replace
  • Index(es):
    • Date
    • Thread