Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
achinsu
- Posts: 1
- Joined: 12 Nov 2012 21:35
#1
Post
by achinsu » 12 Nov 2012 22:19
Hi!
I am newbie with DOS but I think it helpfull for my daily situation, so can You help me. I have to calssifie alot of *.txt files in C:\Source to C:\Destination by strings content in txt file. In my Litsfiles.txt, there are some strings in lines: line1=" String 001" line1=" String 002" ,... lineN="String N" . I have to read LitsLifes.txt to find and move all the *.txt files in C:\Source that content "strings 1" to C:\Destination\String1 folder ; all the *.txt files in C:\Source that content "strings 2" to C:\Destination\String2 folder ; and so on. I can do it with windows search, but manually.
So pls to Help me!!

-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#2
Post
by foxidrive » 13 Nov 2012 00:19
EDIT: changedstrings are in listfile.txt and the c:\source needs to be set.
Code: Select all
@echo off
set "dest=c:\destination"
for /f "delims=" %%a in ('dir "c:\source" /a:-d /o:n /b') do (
for /f "delims=" %%b in (listfile.txt) do (
if exist "%%a" if /i not "%%a"=="listfile.txt" if /i not "%%~nxa"=="%~nx0" find /i "%%b" < "%%a" >nul && (
echo moving "%%a"
md "%dest%\%%b" 2>nul
move "%%a" "%dest%\%%b"
)
)
)
pause