How to rename files like 00080.jpg to 01080.jpg?
Moderator: DosItHelp
How to rename files like 00080.jpg to 01080.jpg?
I need to change one digit from 0 to 1.
Also another example would help how can I change files like 99080.jpg
to 099080.jpg
(add one zero to left).
Also another example would help how can I change files like 99080.jpg
to 099080.jpg
(add one zero to left).
Last edited by doscode on 26 Aug 2016 08:23, edited 1 time in total.
Re: How to rename files like 00080.jpg to 01080.jpg?
Simple use of REN [RENAME]:and
Code: Select all
Ren 00080.jpg 01080.jpg
Code: Select all
Ren 99080.jpg 099080.jpg
Re: How to rename files like 00080.jpg to 01080.jpg?
But I have hundreds of files like this.
Never mind, I found how to do it.
simply
I can replace it in editor.
Never mind, I found how to do it.
simply
Code: Select all
dir *.jpg /o:e /b > list.txt
I can replace it in editor.
Re: How to rename files like 00080.jpg to 01080.jpg?
I guess you could get a better solution if you provide more details:
We don't see what files you are working on, and we also don't know what you want to change.
Details missing:
1) Which digit do you want to change from 0 to 1:
The second digit from left, the fourth digit from right, the third zero digit from right, or how do you find the zero digit to replace?
2) What do you mean with "How to rename files like 00080.jpg to 01080.jpg?" (same for your second task)?
- 00000.jpg, 00010.jpg, 00020.jpg, 00030.jpg, ... == 000[0-9]0.jpg
- 00080.jpg, 00080.gif, 00080.png, 00080.txt, ... == 00080.<extension>
- 00000.jpg, 00001.gif, ... 00098.png, 00099.png == 000[0-9][0-9].jpg
- [0-9]0[0-9][0-9][0-9].jpg
penpen
We don't see what files you are working on, and we also don't know what you want to change.
Details missing:
1) Which digit do you want to change from 0 to 1:
The second digit from left, the fourth digit from right, the third zero digit from right, or how do you find the zero digit to replace?
2) What do you mean with "How to rename files like 00080.jpg to 01080.jpg?" (same for your second task)?
- 00000.jpg, 00010.jpg, 00020.jpg, 00030.jpg, ... == 000[0-9]0.jpg
- 00080.jpg, 00080.gif, 00080.png, 00080.txt, ... == 00080.<extension>
- 00000.jpg, 00001.gif, ... 00098.png, 00099.png == 000[0-9][0-9].jpg
- [0-9]0[0-9][0-9][0-9].jpg
penpen
Re: How to rename files like 00080.jpg to 01080.jpg?
I have explained it:
I need to change one digit from 0 to 1. That is the change. And I said files not one file.
It is clear from the example:
00080.jpg changed to 01080.jpg
I need to change one digit from 0 to 1. That is the change. And I said files not one file.
It is clear from the example:
00080.jpg changed to 01080.jpg
Re: How to rename files like 00080.jpg to 01080.jpg?
doscode wrote:Also another example would help how can I change files like 99080.jpg
to 099080.jpg
(add one zero to right).
Do you mean your other right (left)?
Re: How to rename files like 00080.jpg to 01080.jpg?
I mean add one zero to left.
Re: How to rename files like 00080.jpg to 01080.jpg?
doscode wrote:I have explained it:
I need to change one digit from 0 to 1. That is the change. And I said files not one file.
It is clear from the example:
00080.jpg changed to 01080.jpg
It's not clear at all because you could have filename clashes during your renaming and you don't have the knowledge to realise that.
You task is explained very poorly.
Re: How to rename files like 00080.jpg to 01080.jpg?
The file name is just number of video frames exported from video sequence to jpeg files. The 00000,jpg representes first frame, and some number like 000180.jpg is the last frame. So what i need to do is either to do mathematical calculation for all the frames (add a constant to variable number) 000150(.jpg)+001000(.jpg) = "001150.jpg" or just to change one digit. Because the number.
Re: How to rename files like 00080.jpg to 01080.jpg?
This might help you (?for both tasks?; untested - actually i have few time):
penpen
Code: Select all
@echo off
setlocal enableExtensions enableDelayedExpansion
:: unsorted list
set "list=list.txt"
:: sorted list
set "slist=slist.txt"
:: constant to add
set "const=1000"
:: assumed there are a maximum of 6 digits in the name
set "prefix=000000"
set "pLength=6"
:: %list% will contain: "<normalized filename>"?"<original filename>"
> "%list%" (
for /F tokens^=1^-2^ delims^=^.^" %%a in ('dir *.jpg /b') do (
set "filename=%%~a"
set "filename=!prefix!!filename!"
set /A "filename=1!filename:~-%pLength%!+const-1!prefix!"
set "filename=!prefix!!filename!"
set "filename=!filename:~-%pLength%!"
echo("!filename!.%%~b"?"%%~a.%%~b"
)
)
:: ensure nothing is overwritten when renaming: sort reverse (== rename biggest numbers first)
sort /r "%list%" /o "%slist%"
:: rename
for /F "usebackq tokens=1-2 delims=?" %%a in ("%slist%") do (
ren "%%~b" "%%~a"
)
endlocal
penpen
Re: How to rename files like 00080.jpg to 01080.jpg?
Thanks. I think CMD is too much complicated for this kind of job. This is quite not easy. It is better to choose different language which is able to do it with very simple commands than using CMD.
Using CMD, the fastest solution is what I suggested: to list the files and send it to bat file, which I can edit using notepad string replace.... This way it is very easy.
Using CMD, the fastest solution is what I suggested: to list the files and send it to bat file, which I can edit using notepad string replace.... This way it is very easy.
-
- Posts: 231
- Joined: 01 Oct 2012 13:32
- Location: Ireland
- Contact:
Re: How to rename files like 00080.jpg to 01080.jpg?
Hi Doscode!
Maybe Dave Benham’s JREN.BAT can do what you want. Requires some knowledge of JavaScript regular expressions.
HTH!
- SB
Maybe Dave Benham’s JREN.BAT can do what you want. Requires some knowledge of JavaScript regular expressions.
HTH!
- SB