• 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: String manipulation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: String manipulation


  • Subject: Re: String manipulation
  • From: Christopher Stone <email@hidden>
  • Date: Fri, 07 Jun 2013 01:48:53 -0500

On Jun 06, 2013, at 17:48, Iurista GmbH <email@hidden> wrote:
Thanks for that feedback, Christopher.
Unfortunately, this script does nothing at all   :-(
______________________________________________________________________

Hey Rudolf,

Hmm...

Okay.  The feedback you sent shows that you have some dates that are not of the form dd.mm.yy but of the form d.mm.yy, so that means you might have some that are d.m.yy.  That makes a difference, and Thomas' regex is a pretty good way to handle it.

I also didn't notice the first time around that you didn't want to retain the '.' separators.  I fixed this in the script below.  It now produces 130601 for the date instead of 13.06.01

I also see there's a bug in the Satimage.osax when joining single-item lists.  I've worked around that too.

Here's the results, step by step (the filename is "9.12.89 BUPO.cwk" extension is hidden)

Okay.  I've made you a movie (available for a week from today):

The movie is slightly off, because I made it before noticing the regex needed to be changed - but hopefully it will still be of value.

Let me know if you still have problems.

--
Best Regards,
Chris

-------------------------------------------------------------------------------------------

try

  

  tell application "Finder"

    

    set theFinderSelection to selection as alias list

    

    if length of theFinderSelection ≥ 1 then
      set {oldTIDS, AppleScript's text item delimiters} to {AppleScript's text item delimiters, linefeed}
      set pathList to theFinderSelection as text
      set AppleScript's text item delimiters to oldTIDS
      set nameList to change "^.+:" into "" in pathList with regexp
      set nameList to change "(\\d{1,2})\\.(\\d{1,2})\\.(\\d{1,2})" into "0\\3.0\\2.0\\1" in nameList with regexp
      set nameList to change "\\d?(\\d\\d)\\.\\d?(\\d\\d).\\d?(\\d\\d)" into "\\1\\2\\3" in nameList with regexp
      set nameList to splittext nameList using linefeed

      

      repeat with i from 1 to (length of theFinderSelection)
        set name of item i of theFinderSelection to item i of nameList
      end repeat

      

    else
      error "No items were selected in the Finder!"
    end if

    

  end tell

  

on error e number n
  set e to e & return & return & "Num: " & n
  tell me to set dDlg to display dialog e with title "ERROR!" buttons {"Cancel", "Copy", "OK"} default button "OK"
  if button returned of dDlg = "Copy" then set the clipboard to e
end try

-------------------------------------------------------------------------------------------

 _______________________________________________
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

  • Follow-Ups:
    • Re: String manipulation
      • From: Iurista GmbH <email@hidden>
    • Re: String manipulation
      • From: Emmanuel LEVY <email@hidden>
References: 
 >String manipulation (From: Iurista GmbH <email@hidden>)
 >Re: String manipulation (From: Iurista GmbH <email@hidden>)

  • Prev by Date: Re: String manipulation
  • Next by Date: Re: String manipulation
  • Previous by thread: Re: String manipulation
  • Next by thread: Re: String manipulation
  • Index(es):
    • Date
    • Thread