move files according to folder names (batch)

November 8, 2011 at 05:50:42
Specs: Windows XP
I want to move files according to folder names.Some folder names have been writen in b2.txt. I'm foreign to DOS.And I learn a little,edit a bat like follow.Please give me some modification.Thanks!!

My b2.txt like this:

conformal coating
memory device

I'm not sure whether "%%i" and "%%j" should be defined first. ("set" command)

@echo off

for /f "delims= tokens=1,2" %%i in (b2.txt) do (
for /f "delims=" %%k in ('dir /s/b/a-d E:\JP-WKA\*.pdf E:\JP-WKA\*.txt ^| findstr /i "%%i"^|findstr /i "%%j"') do (
for /f "delims=" %%l in ('dir /s/b/a:d-h E:\ ^| findstr /i "%%i"^|findstr /i "%%j" 2^>nul') do (
if not "%%l"=="" move "%%k" "%%~dpl" >nul 2>nul
)))
pause


See More: move files according to folder names (batch)

Report •


#1
November 26, 2011 at 15:28:47
I have solved it by myself.

Report •
Related Solutions


Ask Question