how to set variable in batchfile

November 26, 2011 at 15:43:20
Specs: Windows XP
I want to move files according to folder names.

1.Some folder names have been written in b2.txt.In my b2.txt,every line contains one or two or three words ,connected by space or "-".Like this:

transfer print
fibre reinforced plastic

2.My files is in "E:\JP-XIN\".

3.In E disk,there must existed one(only one) folder name containing one line in b2.txt.

My question is how to set exactly every line in b2.txt as variable.

In follow code,"%%k" is file name gotten by searching,"%%l" is path to the folder gotten by searching.The code worked not accurately.

@echo off
for /f "delims=" %%a in (b2.txt) do (
set VAR=%%a
for /f "delims=" %%k in ('dir /s/b/a-d E:\JP-XIN\*.pdf E:\JP-XIN\*.txt ^| findstr /i /c:"!VAR!"') do (
for /f "delims=" %%l in ('dir /s/b/a:d-h E:\ ^| findstr /i /c:"!VAR!"') do (
if not "%%l"=="" move "%%k" "%%~fsl"

See More: how to set variable in batchfile

Report •

November 29, 2011 at 05:28:23
I find my code have some wrong and my txt designed imperfectly.Finally ,I get answer.Thanks all to help me!Best wishes!

Report •
Related Solutions

Ask Question