Computing.Net > Forums > Disk Operating System > help w/ a simple batch file - pleas

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

help w/ a simple batch file - pleas

Reply to Message Icon

Name: TommyCee
Date: August 30, 2008 at 18:49:26 Pacific
OS: XP
CPU/Ram: 1GB
Product: HPxw4400
Comment:

I had a directory of filenames like this:

rank(all)_so2_1hr_conc_A_2p5h10.dat

and wanted to crop

rank(all)_so2_1hr_conc_

I discovered a nice way to do this was by using this:

@echo off
for %%i in (*.dat) do (set fName=%%i) & call :rename
goto :eof
:rename
:: Crops the 1st 23 characters of fName ('rank(all)_so2_1hr_conc_'):
ren %fName% %fName:~23%
goto :eof

This results in this:

A_2p5h10.dat

Now I need to convert this to:

A_2p5h100.dat

Notice 'h10' needs top be 'h100'. Can you please suggest a routine that will add the '0' in the middle of the file name? There are hundreds of file names in the directory that need to have this conversion.

Thanks,
Tommy



Sponsored Link
Ads by Google

Response Number 1
Name: Fist (by fmwap)
Date: August 30, 2008 at 19:28:33 Pacific
Reply:

well, I would be using unix stuff to do it - you can grab unixkit for windows & it'll give you this stuff.

ls | cut -d'_' -f5-

should give A_2p5h10.dat

Add:
| awk -f"." '{print $1"0.dat"}'

Should do it


0

Response Number 2
Name: Mechanix2Go
Date: August 31, 2008 at 00:55:37 Pacific
Reply:

Neither unix nor XP are DOS.

[hint: this is the DOS forum]


=====================================
If at first you don't succeed, you're about average.

M2


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


partition problem Auto-insert in DOS prompt



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: help w/ a simple batch file - pleas

Need help with a Dos batch file www.computing.net/answers/dos/need-help-with-a-dos-batch-file/13006.html

batch files hurt my head...help www.computing.net/answers/dos/batch-files-hurt-my-headhelp/7005.html

Simple Batch File www.computing.net/answers/dos/simple-batch-file/5910.html