Re: renaming files in directory
Royce wrote:
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
Your problem is that your file names contain spaces and parentheses.
:-)
- - - - - - - - - - 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
--
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
.
Relevant Pages
- Re: renaming files in directory
... phil when i try it this is what i get... ... 39The syntax of the command is incorrect. ... (microsoft.public.win2000.cmdprompt.admin) - Re: renaming files in directory
... 18A duplicate file name exists, or the file cannot be found. ... I always have it enabled by default, so for me it's possible to use the single command at the CMD prompt to accomplish the renaming. ... 39The syntax of the command is incorrect. ... (microsoft.public.win2000.cmdprompt.admin) - Re: The format of filename
... Windows lets me use '/' as a path separator, ... The syntax of the command is incorrect. ... (comp.lang.python) - Re: dsget - delete header info in output?
... Getting "The syntax of the command is incorrect." ... UsrDNE. ... (microsoft.public.windows.server.active_directory) - Re: Accesing structures data (getting lengthy!)
... According to the syntax you ... assignment statement just won't stand out amongst all the other ... meaningless dummy variables that you have to keep track of. ... comparitively easy to pick out of a long, boring, command line history, ... (comp.soft-sys.matlab) |
|