问题
I have two .txt files. The first one contains the list of pathes to the CD-Images:
C:\Users\N\Desktop\LOG_Dateien_CD_Imaging\BFU_KONGRESS_9.ISO
C:\Users\N\Desktop\LOG_Dateien_CD_Imaging\NDC2005.ISO
The second one contains the new names for this files
490628001
684654326
So the file BFU_KONGRESS_9.ISO
in the directory (not in the .txt file!) should be renamed to 490628001.ISO
and NDC2005.ISO
to 684654326.ISO
. The renaming should go line per line
回答1:
you need a way to read two files in parallel:
@echo off
setlocal enabledelayedexpansion
<out.txt (
for /f "delims=" %%a in (in.txt) do (
set /p out=
echo rename "%%~a" "!out!"
)
)
Another way: read both files (one after the other) into two arrays and then work with the array variables, but it's more code and might have issues with very large files.
来源:https://stackoverflow.com/questions/43005718/how-to-rename-the-files-in-the-path-with-the-new-names-from-the-txt-file-in-bat