P
P
Pavel2018-03-21 12:38:56
cmd/bat
Pavel, 2018-03-21 12:38:56

How to add multiple titles to the search loop?

there is a script

set t=E:\log.txt
set c=E:\ff
:: на каких дисках искать
dir /b /s a:\>%t%
dir /b /s b:\>>%t%
dir /b /s c:\>>%t%
dir /b /s d:\>>%t%
dir /b /s e:\>>%t%
dir /b /s f:\>>%t%
dir /b /s g:\>>%t%
rem ................
dir /b /s y:\>>%t%
dir /b /s z:\>>%t%
md %c%\
:: удалить все существующие файлы из папки куда будут складыватся новые файлы
del /F /Q "%c%\*.*" 2>nul
For /F "Delims=" %%I in ('^<"%t%" find /i ".jpg"') do copy "%%I" "%c%\"
:: удалить лог файл
del /F /Q "%t%" 2>nul
pause

it creates a log.txt file with a list of all files that are in the specified location, then searches the list for .jpg files and copies everything to the specified folder.
I had at least 2 problems: how to set several file extensions for sampling in a cycle and how to exclude folders like windows, program files and their subfolders from the search .. and it would also be nice not to copy files that are less than Y kb.
Tell me how to do it? I first added another cycle that I was already looking for by a different file extension, but I realized that there are a lot of variations of file extensions and running 5+ cycles is a stupid idea that will drag on for a long time.
Can there be an easier option and am I writing all this in vain? As they say, why reinvent the wheel?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
res2001, 2018-03-21
@mrusklon

It is better to filter not in for, but directly in dir: And your for is transformed into this form
Alternative:
I would do everything on xcopy. Examine her keys: xcopy /?
This is a powerful enough command, in my opinion, a few calls to it can replace your entire script.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question