Re: Command Line Question about Renaming Files
From: Pegasus \(MVP\) (I.can_at_fly.com)
Date: 03/24/04
- Next message: eveversion4: "Re: Adding screensavers in Windows 2000 Pro"
- Previous message: Pegasus \(MVP\): "Re: Command Line Question about Renaming Files"
- In reply to: Pegasus \(MVP\): "Re: Command Line Question about Renaming Files"
- Next in thread: Mark & Mary Ann Weiss: "Re: Command Line Question about Renaming Files"
- Reply: Mark & Mary Ann Weiss: "Re: Command Line Question about Renaming Files"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 24 Mar 2004 17:23:20 +1100
"Pegasus (MVP)" <I.can@fly.com> wrote in message
news:u7LLgeWEEHA.2404@TK2MSFTNGP11.phx.gbl...
>
> "Mark & Mary Ann Weiss" <mweissX294@earthlink.net> wrote in message
> news:Hn98c.5139$HP.4959@newsread2.news.atl.earthlink.net...
> > I have a large number of files that begin with "01-", 02-", and so on.
The
> > filenames are varying lengths, but the extension is always 3 characters.
> >
> > Using the Windows 2000 command line, is it possible to batch rename
these
> > files such that the first three characters are stripped from the
filename?
> > If so, can someone post an example?
> >
> > --
> > Take care,
> >
> > Mark & Mary Ann Weiss
> >
> > VIDEO PRODUCTION . FILM SCANNING . AUDIO RESTORATION
> > Hear my Kurzweil Creations at: http://www.dv-clips.com/theater.htm
> > Business sites at:
> > www.dv-clips.com
> > www.mwcomms.com
> > www.adventuresinanimemusic.com
> > -
>
> Try this batch file. Note that it won't to its job properly
> if you end up with ambiguous names. For example, if
> you have these two files
>
> HisMusic.rm
> HerMusic.rm
>
> then there will be an obvious clash.
>
> @echo off
> if exist %temp%\NewName.bat del %temp%\NewName.bat
>
> for %%* in (*.*) do call :Strip %%*
> call %temp%\NewName.bat
> del %temp%\NewName.bat
> goto :eof
>
> :Strip
> set name=%*
> set NewName=%name:~3%
> echo ren "%Name%" "%NewName%" >> %temp%\newname.bat
>
>
To avoid unpleasant surprises because of unexpected behaviour,
you should probably run this version of the batch file first. It only
pretends to go through the motions but it won't rename any files.
@echo off
if exist %temp%\NewName.bat del %temp%\NewName.bat
for %%* in (*.*) do call :Strip %%*
echo Examine %temp%\NewName.bat to see what will happen,
echo then execute %temp%\NewName.bat.
rem call %temp%\NewName.bat
rem del %temp%\NewName.bat
goto :eof
:Strip
set name=%*
set NewName=%name:~3%
echo ren "%Name%" "%NewName%" >> %temp%\newname.bat
- Next message: eveversion4: "Re: Adding screensavers in Windows 2000 Pro"
- Previous message: Pegasus \(MVP\): "Re: Command Line Question about Renaming Files"
- In reply to: Pegasus \(MVP\): "Re: Command Line Question about Renaming Files"
- Next in thread: Mark & Mary Ann Weiss: "Re: Command Line Question about Renaming Files"
- Reply: Mark & Mary Ann Weiss: "Re: Command Line Question about Renaming Files"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|