Computing.Net > Forums > Disk Operating System > DOS Batch rename from file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

DOS Batch rename from file

Reply to Message Icon

Name: stockmode
Date: October 24, 2007 at 00:05:26 Pacific
OS: xp pro
CPU/Ram: 512
Product: inspiron 4100
Comment:

Please help!

i want to rename hundreds of files from my local directory by getting a string from the file.

for example:
filename: abc123.edi

i want to rename it to inlcude the string from inside the file. The file contains a line with

FTM+123456
BGM+123+987654321
DGN+987+AAA

i want to get 987654321 from the line of BGM then append it to the end of the file.

the final filename should look like:
abc123.edi.987654321

then proceed with the next file!


please help!!

if something will go wrong, it will go wrong.



Sponsored Link
Ads by Google

Response Number 1
Name: IVO
Date: October 24, 2007 at 01:53:40 Pacific
Reply:

I could help but my post will be erased as this Forum is for plain DOS only and you require a NT (XP) batch solution.

So post in the Programming Forum and you will get what you need.


0

Response Number 2
Name: Mechanix2Go
Date: October 24, 2007 at 06:04:47 Pacific
Reply:

Assuming ypu're using NT... [this won't fly in DOS]

============ renEDI.bat
@echo off
setLocal EnableDelayedExpansion

for /f "tokens=* delims= " %%a in ('dir/b/a-d *.edi') do (
for /f "tokens=* delims= " %%f in ('type %%a ^|find "BGM"') do (
for /f "tokens=3 delims=+" %%s in ('echo %%f') do (
ren %%a %%a.%%s
)
)
)



=====================================
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







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: DOS Batch rename from file

Dos batch file fro connecting to ftp www.computing.net/answers/dos/dos-batch-file-fro-connecting-to-ftp/6153.html

Help with DOS Batch renaming www.computing.net/answers/dos/help-with-dos-batch-renaming/10410.html

DOS batch to check file dates www.computing.net/answers/dos/dos-batch-to-check-file-dates/13578.html