samintz wrote:
| I was going to suggest using the newer syntax of regular expressions
| and delayed expansion to accomplish the task in a single rename
| statement but
| 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
Two independent simplifications.
1/ Use touch/c to create empty files.
2/ Use for/l %c in (10001,1,10010) in the loop, and use %@right[4,%c] in the
file name. This is simpler in some contexts, though in the present context
may not actually be faster or easier to understand. BTW, I have UDFs for
fz2=`%@format[02,%1]` through fz9 to simplify the task using your control
variable.
|
| 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
| 11th)
| to the last 4 digits and the extension.
|
| @name appears to work but @right is failing miserably.
Using TCC 9.02.151 Windows XP [Version 5.1.2600] (in its own window) I
found the same issue with the command
ren *_[0-9][0-9][0-9][0-9].jpg %%@right[8,*]
the target names were identical to the source names. However, puuting
quotation marks around the target name thus:
ren *_[0-9][0-9][0-9][0-9].jpg "%%@right[8,*]"
worked like a charm. It properly renamed files 1..10, and left alone the
"1a" file.
--
Steve