Help with the Dos batch File

March 19, 2009 at 13:45:59
Specs: Windows XP
Can some one please help me with batch file. I am trying to create a batch file for multiple files which will check the first 17 characters of the file name compare against the text in the filname.txt file, if the text is found than copy the matching file to C:\fileprocessing.

See More: Help with the Dos batch File

Report •

March 19, 2009 at 16:28:01
:: get first 17 chars of filename and look up in filname.txt [sic]

@echo off & setLocal EnableDelayedExpansion

for /f "tokens=* delims= " %%a in ('dir/b/a-d') do (
set fname=%%~Na
::echo !fname!
set first17=!fname:~0,17!
::echo firat 17 chars are !first17!
find /i "!first17!" < filname.txt > nul
if !errorlevel! equ 0 (
copy %%a C:\fileprocessing > nul

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


Report •

March 20, 2009 at 08:45:13
Thanks M2, it works

Report •

Related Solutions

Ask Question