This sort of technique was shown recently.
It will work if the number of lines in log.log is equal to the number of *.txt files.
The renaming is in alphabetical order as the DIR command returns the filenames.
remove the echo command to make it work.
Code: Select all
< "log.log" (for /f "delims=" %%a in ('dir *.txt /b /o:n') do (
set /p "var="
if defined var echo ren "%%a" "!var!%%~xa"
First, what's the use of the redirect output operator?
And a lot more I cannot make sense of...
The FOR loop is inside a ()
Why set var = nothing?
to unset the variable %var%?
Is it to reset the variable with the delayed expansion?
SET /P "var="
It waits for users to enter a value for %var%.
If the user does not enter anything, the variable is still empty. Then what's the use of it in this case?
If SET var=nothing, why var is defined?
Sorry if I've asked too much.
I couldn't figure out most of them online on my own.