Hello!
I have files in a folder:
Listing-01-01.txt
Listing-01-02.txt
Listing-02-01.txt
Listing-02-02.txt
Listing-02-03.txt
Listing-03-01.txt
50 more similar files.
I need to rename them to be:
L01-01.txt
L01-02.txt
L02-01.txt
L02-02.txt
L02-03.txt
L03-01.txt
and do the same for all the other 50 files in the folder.
How can I do it with REN command?
Thanks!
Shorten file names with REN
Moderator: DosItHelp
Re: Shorten file names with REN
Tokenize the file names in a FOR /F loop.
Steffen
Code: Select all
pushd "C:\your\folder"
for /f "tokens=1* delims=-" %%i in ('dir /a-d /b "Listing-*.txt"') do ren "%%i-%%j" "L%%j"
popd