Re: looking for regex help
Re: looking for regex help
- Subject: Re: looking for regex help
- From: Christopher Stone <email@hidden>
- Date: Fri, 25 Nov 2011 11:50:03 -0600
On Nov 25, 2011, at 09:27, Robert Poland wrote: I'm using these lines to set the replacement of file names;
property searchStrings : ["^"] property replacementStrings : ["{1, 1, 2}-"]
Obviously I'm doing something wrong as the result is;
filename --> {1, 1, 2}-filename
What I want is for the filename to be preceded with an incrementing number and a dash starting with one;
filename --> 01-filename --> 02-filename
______________________________________________________________________
Hey Bob,
Firstly:
Are you using the Satimage.osax to do this?
Secondly:
searchStrings == {"^"} replacementStrings == {"{1, 1, 2}-"}
This is what your bracket notation is producing.
Thirdly:
Although I think there's a very fancy way of referencing match-number with Perl, you're probably better off doing something similar to this:
# This is just to populate a list of file names for testing: tell application "Finder" set sel to selection as alias list repeat with i in sel set contents of i to (i's name) end repeat end tell
# This is the rename code: repeat with i from 1 to length of sel set fNum to (format i into "00") & "-" set item i of sel to change "^" into fNum in (item i of sel) with regexp end repeat
sel
'change' and 'format x into' are from the Satimage.osax.
The 'format into' command allows easy zero-padding of number and several other functions for formatting reals.
When I do mass renames I usually preprocess all the changes and then do the renaming. One reason is that I can check for dupes and abort the rename if there are any.
-- Best Regards, 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