Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Please help!
i want to rename hundreds of files from my local directory by getting a string from the file.
for example:
filename: abc123.edii 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+AAAi 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.987654321then proceed with the next file!
please help!!if something will go wrong, it will go wrong.

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.

Assuming ypu're using NT... [this won't fly in DOS]
============ renEDI.bat
@echo off
setLocal EnableDelayedExpansionfor /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

![]() |
![]() |
![]() |

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