jirwin wrote:Hello,
I am attempting to rename files that are named sequentially via Windows Copy. Specifically, the filenames look like the following:
img_20080423095549.jpg
img_20080423095549(1).jpg
img_20080423095549(10).jpg
img_20080423095549(2).jpg
...
Essentially I would like the above files to be renamed to the following (respectively):
000.jpg
001.jpg
010.jpg
002.jpg
I spent a lot of time reading existing postings, but there are two issues that I cannot figure:
1. How can I add padding that will work when I have one, two or three digits. i.e. how can i add one zero to 10 but two zeros to 2?
2. How can the first filename (which doesn't contain an integer) be renamed to 001.jpg?
I would appreciate any help anyone can provide,
Thank you
Jason
Jason >1. How can I add padding that will work when I have one, two or three digits.
First add a many of leading 0's to match all possibilities, then rename to keep the last few signs (here three) only.
Jason >2. How can the first filename (which doesn't contain an integer) be renamed to 001.jpg?
You mean to: 000.jpg
Just rename all possible others first, then the last without that integer inside ( ) will be easy to catch by the "img_" part.
Perhaps i will find an more elegant solution, but this is my first try:
First backup all your files to rename, or use copies of your real files only!FROM:
img_20080423095549(1).jpg
img_20080423095549(2).jpg
img_20080423095549(10).jpg
img_20080423095549.jpg
TO:
1.jpg
2.jpg
10.jpg
img_20080423095549.jpg
DO:
RegEx(1)
Match: .+\((\d+).*
Repla: \1
[Rename]
Then
FROM:
1.jpg
2.jpg
10.jpg
img_20080423095549.jpg
TO:
001.jpg
002.jpg
0010.jpg
000.jpg
DO:
RegEx(1)Match: img_.+
Repla: 0
Add(7)Prefix: 00
[Rename]
Then
FROM:
001.jpg
002.jpg
0010.jpg
000.jpg
TO:
001.jpg
002.jpg
010.jpg
000.jpg
DO:
RegEx(1)Match: .*(...)
Repla: \1
[Rename]
HTH at first?

.