-
February 10th, 2010, 02:34 AM
#1
Renaming multiple files in DOS
Hi All,
I am in a situation like this:
I have close to 100 files ordered like this:
test1.txt
test2.txt
test3.txt
...
...
test99.txt
I need to rename those files like this:
track1.txt
track2.txt
...
...
track99.txt
i.e. trackNN.txt
Of course, with windows, I can rename them whatever I like one by one.
But with commad prompt (DOS command) how do I do that?
ren test*.txt track*.txt did not work
I want to change the alphabet part, leaving the numerals intact.
Is it possible?
Thank you for your time.
Best,
T.
-
February 10th, 2010, 09:34 AM
#2
Re: Renaming multiple files in DOS
There is no easy way to do this in a ".bat" file.
Instead you could do this in VBS (VBS is the scripting language supposed to replace old DOS commands, and is available since Windows 95).
Or, better, use a good third party tool, e.g. ant renamer. See http://www.antp.be/software/renamer
-
February 10th, 2010, 07:22 PM
#3
Re: Renaming multiple files in DOS
Pretty sure you can use a SINGLE-CHARACTER WILDCARD. Not sure if it's & or _
Code:
ren t&&&*.txt track*.txt
Otherwise, look into POWERSHELL. It can do that
-
February 11th, 2010, 09:17 PM
#4
Re: Renaming multiple files in DOS
Hi olivthill2, dglienna,
Thank you for your answers.
ren t&&&*.txt track*.txt and ren t___*.txt track*.txt did not work.
I will have to use some other ways. Let's see if I can use powershell- never used this before.
T
-
February 11th, 2010, 09:43 PM
#5
Re: Renaming multiple files in DOS
I don't know if this works on all windows computers, but on windows vista if you select all the files you want to rename, then press F2, it'll allow you to rename a file and then it will take that same name and name all the files selected under that name and number them. Pretty easy and convenient alternative.
-
February 12th, 2010, 12:54 AM
#6
Re: Renaming multiple files in DOS
Hi,
Yes, even in my XP, it works. I mean it renames files like track (1).txt, track (2).txt, etc.
Unfortunately, for my purpose, that was not useful.
The end device that uses the files (track1.txt, track2.txt.....) could not read track (1).txt, track (2).txt, etc.
Thanks.
-
February 12th, 2010, 08:00 PM
#7
Re: Renaming multiple files in DOS
Once again, try VBSCRIPT
Code:
Const ForReading = 1
strComputer = "."
set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("c:\scripts\names.txt", ForReading)
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
arrParts = Split(strLine, ",")
strFile = "C:\\Pictures\\" & arrParts(0)
Set colItems = objWMIService.ExecQuery _
("Select * From CIM_Datafile Where Name = '" & strFile & "'")
For Each objItem in colItems
strNewName = "C:\Pictures\" & arrParts(1)
objItem.Rename strNewName
Next
Loop
objFile.Close
http://blogs.technet.com/heyscriptin...text-file.aspx
-
February 14th, 2010, 12:44 PM
#8
Re: Renaming multiple files in DOS
Hi dglienna,
Thanks for the post.
-
February 14th, 2010, 03:46 PM
#9
Re: Renaming multiple files in DOS
If you install Cygwin, the following will work in the Cygwin prompt:
Code:
cd "/cygdrive/c/Documents and Settings/whatever folder/the files are in/"
for i in `ls` ; do mv $i `echo $i | sed "test/track/"`; done
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|