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
anti-foamer
insect
fibre reinforced plastic2.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
setlocal ENABLEDELAYEDEXPANSION
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"
)))
pause
I find my code have some wrong and my txt designed imperfectly.Finally ,I get answer.Thanks all to help me!Best wishes!
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |