So an actual syntax that works is:
ren "::.*_\d+\.jpg" "%%@right[8,*]"
The RegEx says: zero or more of any character (.*) followed by underscore
(_) followed by 1 or more numeric digits (\d+) followed by .JPG (\.jpg).
Delayed expansion can then be used to manipulate the name anyway you want.
However, I tried to get a more generic solution for a file that starts
with arbitrary characters, an underscore, followed by an arbitrary number
of digits, then .jpg. The @right works above because the filenames all
have 4 digits at the end of their names. So I tried to use @REGEXSUB.
ren /n "::.*_\d+\.jpg" "%%@regexsub[1,(\d+)$,%%@name[*]].jpg"
But the REN statement does not. What's wrong with my syntax?
rconn <> wrote on 06/16/2008 02:58:55 PM:
> > I was going to suggest using the newer syntax of regular expressions
> > delayed expansion to accomplish the task in a single rename statement
> > I think I've uncovered a glitch.
> > I created 10 files:
> > for /l %c in (1,1,10) do echo. >file_%@format[04,%c].jpg
> > Then I created an 11th special case:
> > echo. >file_0011a.jpg
> > Then I tried to rename it using this syntax:
> > ren /n "::.*_\d\d\d\d\.jpg" %%@right[8,*]
> > Which in theory should rename the files (with the exception of the
> > to the last 4 digits and the extension.
> > @name appears to work but @right is failing miserably.
> Nothing to do with @RIGHT; the problem is because you've failed to quote
> the target. The ',' inside @RIGHT is being interpreted as an argument
> separator (whitespace), so REN thinks the target filename is supposed to
> be "*]". I tried it here with the quotes in place and it worked as
> Rex Conn
> JP Software