Home > OS >  Windows batch bulk modify the file name
Windows batch bulk modify the file name

Time:09-19

File directory has sorted multiple pictures, named: 1. JPG 2. JPG... Main pg
Existing filename file id. TXT, content is sorted id, each id takes up a row, including graphics is consistent with the id number of rows, as follows:
1111
2222

Now need to CMD command, the bulk of the picture instead with index id in the file, as follows:
1. JPG - & gt; 1111 JPG
2. JPG - & gt; 2222 JPG

Ever try scripts, but is invalid, why after goto jumped out of the two layers of cycle? Master:
@ echo on
Set the line=0
For/f % % a in (' dir/b *. JPG) do (
For/f delims="line" skip=% % % % I in (id. TXT) do (
The set id=% % ~ I
Echo 'filenam:' a 'count:' % % % % I
Goto: next
)
: next
# used here copy command to change the file name
Copy a image \ % % % % id. The JPG
The set/a line +=1
)
Echo line % %
)

CodePudding user response:

For/F don't support variable expansion in the options? For probably doesn't support nested,
If I could take a direct id in the excel. TXT of ren commands into the final one by one batch, then run it directly,

CodePudding user response:

Writing for seems to be a lot of line, but the CMD regard it as a line read, want to use setlocal delay variables,
Nested for really bad for debugging, there will be strange things happen, better call a subroutine,
You need not use nested for, your code efficiency is very low,
  • Related