Hi, new to the forum and batch files in general. I am looking to rename 2 text files from a floppy and cut and copy them to a folder on my hard drive. Specifically the floppy will have a LOG.TXT and a LOGDEL.TXT file on it. I want to copy the file from the floppy, rename it based on contents in the text file (line and column specified), paste it to a folder on my hard drive and then delete the file from the floppy. e.g. Find and copy log.txt, rename it log_1234567.txt, paste to specified directory, delete log.txt from the floppy and do the same for logdel.txt.
Any help is appreciated.
If you're using, let's say, row 2, column 3: =====================================
@echo off & setLocal EnableDELAYedeXpansionset N=
for /f "tokens=1-3 delims= " %%a in (a:\LOG.TXT) do (
set /a N+=1
if !N! equ 2 set T=%%c
)move a:\LOG.TXT d:\LOG_!T!.TXT
=====================================
Helping others achieve escape felicityM2
Thanks for the response. The batch successfully moves the file but is renaming LOG_.txt. I put the following in to a text file to test the batch: 1234567890abcdefghijkl
mnopqrstuvwxyz1a2a3a4a
5a6a7a8a9a0a1b2b3b4b5b6b
7b8b9b0b1c2c3c4c5c6c7c8cWhat I would like to do is, for example, capture 7 characters from line 2 starting with s, so the new file name should be LOG_stuvwxy.txt. Is this possible?
@echo off & setLocal EnableDELAYedeXpansion set N=
for /f "tokens=* delims= " %%a in (f:\LOG.TXT) do (
set /a N+=1
if !N! equ 2 set T=%%a
)set T=!T:~6,7!
move f:\LOG.TXT d:\LOG_!T!.TXT
=====================================
Helping others achieve escape felicityM2
That did it, thanks for your help!
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |