rename multiple files with shorter name

C

Charles T

Greetings Group,
I want to rename multiple files in a folder, but
shortening their names in the process, e.g.
from ABCD0064.csv to p064.csv
from ABCD0123.csv to p123.csv
from ABCD0256.csv to p256.csv
That is the last three characters (and extension) to
remain unchanged.
I've tried wild cards to no avail. Any assistance
gratefully received, as I've got 267 files (so far) to
rename.
Thanks and Regards all.
 
M

Matthias Tacke

Charles T said:
Greetings Group,
I want to rename multiple files in a folder, but
shortening their names in the process, e.g.
from ABCD0064.csv to p064.csv
from ABCD0123.csv to p123.csv
from ABCD0256.csv to p256.csv
That is the last three characters (and extension) to
remain unchanged.
I've tried wild cards to no avail. Any assistance
gratefully received, as I've got 267 files (so far) to
rename.
Thanks and Regards all.

Hello Charles,
this batch requires w2k/xp.

::RenCSV.cmd:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
setlocal
For %%A in (ABCD*.CSV) do call :sub "%%~A"
goto :eof
:sub
set Name=%~n1
echo ren %1 "p%Name:~-3%.csv
::RenCSV.cmd:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

if the output seems ok remove the echo in the last line.
 
G

Guest

Thank you Matthias
-----Original Message-----


Hello Charles,
this batch requires w2k/xp.

::RenCSV.cmd:::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::
@echo off
setlocal
For %%A in (ABCD*.CSV) do call :sub "%%~A"
goto :eof
:sub
set Name=%~n1
echo ren %1 "p%Name:~-3%.csv
::RenCSV.cmd:::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::

if the output seems ok remove the echo in the last line.
--
Greetings
Matthias________________________________________
For help on nt commands enter in a cmd window:
W2K>HH windows.chm::ntcmds.htm XP>HH ntcmds.chm
.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top