Re: Command Line Question about Renaming Files
From: Mark & Mary Ann Weiss (mweissX294_at_earthlink.net)
Date: 03/25/04
- Next message: Pegasus \(MVP\): "Re: Command Line Question about Renaming Files"
- Previous message: Steve E.: "Files? being automatically deleted"
- In reply to: Pegasus \(MVP\): "Re: Command Line Question about Renaming Files"
- Next in thread: Pegasus \(MVP\): "Re: Command Line Question about Renaming Files"
- Reply: Pegasus \(MVP\): "Re: Command Line Question about Renaming Files"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 25 Mar 2004 01:43:20 GMT
> > :Strip
> > set name=%*
> > set NewName=%name:~3%
> > echo ren "%Name%" "%NewName%" >> %temp%\newname.bat
> >
> >
> > I have a vague idea of what is intended and that the key here is the
"~3%"
> > portion, but I tried the set command one line at a time to see if the
> > environment would accept it and all that became persistent was "set
> > name=%*". The line after it might be invalid, as setting that does not
> > include it in the environment.
> >
> > What exactly does the "~3%" statement do? Does it mean "delete first
three
> > characters? What does "~" mean in this context?
> >
> >
> > --
> > 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
> > -
>
> I am puzzled as to what's going on on your machine. Are
> you running Win2000?
>
> I have modified the batch file to add some diagnostics.
> Run it again until it throws up the first error, then post
> a screen dump.
>
> @echo on
> if exist "%temp%\NewName.bat" del "%temp%\NewName.bat"
>
> for %%* in (*.*) do (call :Strip %%* & pause)
> 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"
>
Win2K SP4 here, to be exact.
I found the problem...
It had to do with how I was sending the commands to the command processor.
I assumed that I could paste it into the cmd window like I do with single
line commands, but apparently the bat file has to exist on the drive for
this bat file to work.
So I pasted to a text file, renamed it 'ren.bat' and copied it to the folder
where I wanted to strip out the first three numerical characters. It works.
It does rename itself in the process and generates an error, but all the
files I wanted renamed are renamed appropriately.
I don't fully understand how your batch file works, but thanks for providing
a solution to my batch renaming challenge.
-- 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 -
- Next message: Pegasus \(MVP\): "Re: Command Line Question about Renaming Files"
- Previous message: Steve E.: "Files? being automatically deleted"
- In reply to: Pegasus \(MVP\): "Re: Command Line Question about Renaming Files"
- Next in thread: Pegasus \(MVP\): "Re: Command Line Question about Renaming Files"
- Reply: Pegasus \(MVP\): "Re: Command Line Question about Renaming Files"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|