Copy/Rename or Script Help

  • Thread starter Thread starter RichLich
  • Start date Start date
R

RichLich

I have a large number of files for which I need to
rename/copy basically by stripping off the first 2
charactes of the file name. So far I've not been able to
get a copy or rename command to do this. Any of you have
any ideas? Do any of you maybe have a script that will do
this?
 
RichLich said:
I have a large number of files for which I need to
rename/copy basically by stripping off the first 2
charactes of the file name. So far I've not been able to
get a copy or rename command to do this. Any of you have
any ideas? Do any of you maybe have a script that will do
this?

Try this:

@echo off
setlocal enabledelayedexpansion

dir /b > "%temp%\dir.txt"

pushd "%temp%"

for /F "tokens=*" %%* in (dir.txt) do (
set old=%%*
set new=!old:~2!
echo ren "!old!" "!new!"
)

popd
endlocal

When you run the batch file in this form then it will tell you what it will
do. To make it do it, remove the "echo" instruction.
 
Back
Top