Code: Select all
@echo off
setlocal enabledelayedexpansion
for %%i in (*.txt) do (set Name=%%~nxi&echo ren "%%i" "!Name:~0,5!-MyNewText-!Name:~5!")
(insert text in the middle of the file name)
But in a single command line:
Code: Select all
@echo off&setlocal enabledelayedexpansion&(for %i in (*.txt) do (set Name=%~nxi&echo ren "%i" "!Name:~0,5!-MyNewText-!Name:~5!"))&echo on
It does not work because of the variable Name
I wonder if there is any way to do this (just curious)