473,403 Members | 2,338 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Renaming files in DOS

24
Hello,

I need to rename files in a folder. I was trying to use DOS ( "ren" ) but was unsuccessful.

Can someone give me a hint how this can be done.

I want the First 3 Chars to be removed from Original file name.

Original FileName: ABC12345.txt, ABC88898.txt, ABC67890.txt

Desired FileName: 12345.txt, 88898.txt, 67890.txt

Thanks,
K
Feb 20 '08 #1
9 1442
Stang02GT
1,208 Expert 1GB
what operating system, are you using?

Cause you can just right click on the file in windows and there should be a "rename" option you can select. Then just edit the file name, unless you absolutely have to you don't need to do this in dos.
Feb 20 '08 #2
Stang02GT
1,208 Expert 1GB
But if you would like to do it in DOS, here is a link to a site that i think we be helpful to you...


http://www.computerhope.com/renamehl.htm
Feb 20 '08 #3
ymk
24
This is in Windows 2000 Pro.

I need some thing like a batch file to do this as there are 100's of files.

I need rename using the wild cards like ( *, ? ). I tried using them but didnt get the desired result.
Feb 20 '08 #4
hsriat
1,654 Expert 1GB
Hello,

I need to rename files in a folder. I was trying to use DOS ( "ren" ) but was unsuccessful.

Can someone give me a hint how this can be done.

I want the First 3 Chars to be removed from Original file name.

Original FileName: ABC12345.txt, ABC88898.txt, ABC67890.txt

Desired FileName: 12345.txt, 88898.txt, 67890.txt

Thanks,
K
If the number part is always 5 digit, and total length is 8, then use this...

ren *?????.* ?????.*
Feb 20 '08 #5
ymk
24
If the number part is always 5 digit, and total length is 8, then use this...

ren *?????.* ?????.*

hsriat,

I tried the same as you suggested but somehow its retaining the first chars than the latter.

ex: for ABC12345.txt, its renaming it as ABC12.txt.
Feb 21 '08 #6
hsriat
1,654 Expert 1GB
hsriat,

I tried the same as you suggested but somehow its retaining the first chars than the latter.

ex: for ABC12345.txt, its renaming it as ABC12.txt.

Yeah, I checked that. It retains the first five.

It's better for you if you consult the C++ guys. They would probably know thae C++ way of renaming.
Feb 21 '08 #7
ymk
24
Yeah, I checked that. It retains the first five.

It's better for you if you consult the C++ guys. They would probably know thae C++ way of renaming.
Thanks hsriat. I am a C++ programmer myself. I thought I could do it in DOS easily but think I have no choice else to write a program.
Feb 21 '08 #8
hsriat
1,654 Expert 1GB
Thanks hsriat. I am a C++ programmer myself. I thought I could do it in DOS easily but think I have no choice else to write a program.
I tried a lot after you said that my previous solution didn't work. Altho I was somewhat good in DOS 10 years ago, I couldn't provide you with a solution. So I suggested you that.

:)
Feb 22 '08 #9
MedIt
15
I tried a lot after you said that my previous solution didn't work. Altho I was somewhat good in DOS 10 years ago, I couldn't provide you with a solution. So I suggested you that.

:)
Hi,
not sure if you have solved this problem, but I have a solution to rename it in batch file!

Assuming that you want to strip off the first 3 characters of your filename:
In your for loop you can do something like:

for /f "usebackq" %%i in (`dir /b /on`) do call :COPY %%i
goto :EOF

:COPY
echo %1
set filename=%1
rem stripping off the first 3 chars
set newF=%filename:~3%
copy %1 %newF%
goto :EOF

This obviously you are using the copy to do the trick, you can get rid of the old(original) file as you rename it to an archive folder.
This should work!
Mar 20 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: MikeY | last post by:
Hopefully someone can help, I have a listview box where I display my desired files. I single click on the desired file to be renamed and I rename it with a new name. My problem arises when the...
16
by: dudufigueiredo | last post by:
I have one folder containing mp3 files, the folder is: C:\My Shared Folder\Rubber Soul And the files are: 01 drive my car.mp3 02 norwegian wood.mp3 03 you won't see me.mp3 04 nowhere man.mp3...
1
by: Don Leverton | last post by:
Hi Folks, I have been given a CD with approx 130 .xls files (bean-counters!) that I would like to import and merge to ONE table (tblTradeshow). The XL files are *similarly*, but not...
3
by: Colin | last post by:
I have two files and I want to rename file B to file A without doing a system call - can I do this in C using file pointers ?
6
by: Pegboy | last post by:
I am trying to create a DOS utility that will extract data from a file and use it to form a new filename for that same file. I can successfully open the file, get the data I need and form the new...
1
by: MikeY | last post by:
Hopefully someone can help, I have a listview box where I display my desired files. I single click on the desired file to be renamed and I rename it with a new name. My problem arises when the...
1
by: farseer | last post by:
HI, i have created a DataSet using the DataSet Designer. The default name is DataSet1. I then renamed this to "MyDataSet" and proceed to add my TableAdapters using the Visual Designer. After i...
1
by: Jack Maxwell | last post by:
Hope someone can help here. My brother has asked me if I can assist in renaming about 1500 midi files which are associated with a programm called Cubase SE. With that software installed he can...
1
by: GeoDW | last post by:
Hell All, I have looked around and not found the solution I am looking for within the old threads. Here is my problem: I have a directory full of .img and .rrd files that have long filenames...
2
by: Alan Mailer | last post by:
I am relatively new to VB.net. I want to change the name of a Project and change the name of the files in the Project's various folders to reflect that new project name. Is there something I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.