• 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: Iurista GmbH <email@hidden>
  • Date: Fri, 07 Jun 2013 19:33:18 +0200

Am 07.06.2013 um 01.29 schrieb Thomas Fischer:

> Hi Rudolf,
>
> this seems overly complicated,
> If you use the Satimage Osax anyway you might try to accomplish the same result using regular expressions:
>
> tell application "Finder"
> 	set myFile to the selection as alias
> 	set oldName to the name of myFile
> 	tell me to set newName to change "(\\d+)\\.(\\d+)\\.(\\d+)" into "\\3.0\\2.0\\1" in oldName with regexp
> 	tell me to set newName to change "\\d*(\\d\\d)\\.\\d?(\\d\\d)\\.\\d?(\\d\\d)" into "\\1.\\2.\\3" in newName with regexp
> 	log oldName
> 	set the name of myFile to newName
> end tell

Thanks Thomas.
I eliminated the dot's in newname, and then it works indeed the way I think, with one limitation:
As long as the syntax of the names to be converted are strictly a kind of   "sometext xx.xx.xx some text", regex can do the job.
The problem (which I probably have not emphasized clearly, mea culpa..mea culpa..) is that the files are a kind of "sometext xx.xx.xx some text" but the xx.xx.xx part may as well be "x. xx. xx" or "xx. x. xx", that means there is no clear pattern. Moreover, dot's may exist also in the text part like "some.text x. xx.xx"

The background:
I have hundreds (if not thousends) of Applework (or even Clariswork) files I'm obliged for legal reasons to keep for still a few years to come. And back in ancient times, neither me nor my office did a systematic datestamping of the files through inserting the date in a strict way in the filename.
That's so far no problem, because if we use the date it's anyhow only for sorting.
But
Actually we still run SnowLeo, and since a few years already, we do use Pages and have also a strict system of labeling the files, in form of "xx.xx.xx| some text", which helps for easier retrieving. But I have to look further: Beyond SnowLeo, Appleworks will not work anymore.

Therefore, I have to convert all AW files to Pages. I made an Applescript for that, and when I'm stumbling over an AW file, it's a job quickly done. And I would also like to convert the "date part" in the filename (if there is any).
Hence a need for copying/changing only a part of the filename, and this part does not show a strict pattern.
Rudolf


--
The basic rule for a more liberal world:
If there's no necessity to make a law, there's a necessity to make no law.

This mail is from:

Rudolf O. Durrer
IURISTA CONSULT GmbH
Legal Counselors
Switzerland

email@hidden
email@hidden

 _______________________________________________
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: 
 >String manipulation (From: Iurista GmbH <email@hidden>)
 >Re: String manipulation (From: Thomas Fischer <email@hidden>)

  • Prev by Date: Re: String manipulation
  • Next by Date: Re: String manipulation
  • Previous by thread: Re: String manipulation
  • Next by thread: Are folder actions in 10.8 completely broken?
  • Index(es):
    • Date
    • Thread