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.
 

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

Back
Top