1.

Solve : filter a text file using batch?

Answer»

Is it possible to use a DOS to EXTRACT FILE names from an text file and copy those files to another DIRECTORY?
example input from text file
03/22/2009 11:10 PM 40,700 btch001338.PRN
03/22/2009 10:27 PM 40,715 btch000425.prn
03/22/2009 10:27 PM 40,727 btch000431.prn
03/22/2009 10:27 PM 40,730 btch000436.prn
03/22/2009 10:27 PM 40,833 btch000435.prn
03/22/2009 10:27 PM 40,922 btch000433.prn
I would like to copy the btch...prn files to another directory from this list.Code: [Select]@ECHO off
REM cut here ------------------------------------------------------------
REM Create test file
REM
echo 03/22/2009 11:10 PM 40,700 btch001338.prn > textfile.txt
echo 03/22/2009 10:27 PM 40,715 btch000425.prn >> textfile.txt
echo 03/22/2009 10:27 PM 40,727 btch000431.prn >> textfile.txt
echo 03/22/2009 10:27 PM 40,730 btch000436.prn >> textfile.txt
echo 03/22/2009 10:27 PM 40,833 btch000435.prn >> textfile.txt
echo 03/22/2009 10:27 PM 40,922 btch000433.prn >> textfile.txt
REM cut here ------------------------------------------------------------


REM edit list file and destination folder names

REM file containing list
set readfile=textfile.txt

REM folder to move files to
set destfolder=C:\Path To\Folder

REM delete the word echo after you have run the file
REM and you are satisfied

for /f "tokens=1-5 delims= " %%A in ( ' type "%readfile%" ' ) do (
echo move "%%E" "%destfolder%"
)


Worked like a charm. Thanks



Discussion

No Comment Found