Re: renaming files in directory
- From: "Royce" <Royce@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 23 Apr 2005 09:50:06 -0700
phil when i try it this is what i get... i have tried messing around with
this for while, but i cant seem to figure out where my problem is. thanks for
the help
- - - - - - - - - - begin screen capture - - - - - - - - - -
C:\>for %a in (c:\new\*.txt) do @(set /a x+=1&echo ren %a !x!%~xa)
35ren c:\new\New Text Document (2).txt !x!.txt
36ren c:\new\New Text Document (3).txt !x!.txt
37ren c:\new\New Text Document (4).txt !x!.txt
38ren c:\new\New Text Document.txt !x!.txt
C:\>for %a in (c:\new\*.txt) do @(set /a x+=1& ren %a !x!%~xa)
39The syntax of the command is incorrect.
40The syntax of the command is incorrect.
41The syntax of the command is incorrect.
42The syntax of the command is incorrect.
- - - - - - - - - - end screen capture - - - - - - - - - -
"Phil Robyn [MVP]" wrote:
> Royce wrote:
> > need help creating a batch file (or a single line command) that renames all
> > the files in the directory to numbers from 1 to however many files are in the
> > directory. they will all have the same extension... im sure there is a post
> > in this group somewhere i just couldnt find it. thanks for any help.
>
> - - - - - - - - - - begin screen capture - - - - - - - - - -
> <Win2000> c:\cmd>for %a in (d:\junkdir\m*.txt) do @(set /a x+=1&echo ren %a !x!%~xa)
> 1ren d:\junkdir\MSGBOX1.TXT 1.TXT
> 2ren d:\junkdir\MVSPKG01.TXT 2.TXT
> 3ren d:\junkdir\MVSPKG02.TXT 3.TXT
> - - - - - - - - - - end screen capture - - - - - - - - - -
>
> If this appears to do what you intend, remove the word 'echo' to actually do the renaming.
> If you try it more than once from the CMD prompt, before the second or subsequent attempts,
> issue the command 'set /a x = 0' to reset the counter 'x' to zero; otherwise, it will
> continue counting up from the previous value.
>
> --
> Phil Robyn
> Univ. of California, Berkeley
>
> u n z i p m y a d d r e s s t o s e n d e - m a i l
>
.
- Follow-Ups:
- Re: renaming files in directory
- From: Phil Robyn [MVP]
- Re: renaming files in directory
- References:
- renaming files in directory
- From: Royce
- Re: renaming files in directory
- From: Phil Robyn [MVP]
- renaming files in directory
- Prev by Date: Re: real text file content
- Next by Date: Re: renaming files in directory
- Previous by thread: Re: renaming files in directory
- Next by thread: Re: renaming files in directory
- Index(es):
Relevant Pages
|