Batch: Bilder (gewisse Nummern) vom Verzeichnis A in einen Ordner Kopieren
Ich bin noch neuling im batchen und brauche eure Hilfe:
Ich muss gewisse Bilder aus einem riesiegen Verzeichnis batchen.
Die Bilder sind (zufällig) Durchnummeriert:
12351234.jpg
12462345.jpg
2351.jpg
2351223.jpg
Mit einem Code hab ich es geschafft die Bennenungen der Bilder mit Hilfe einer Liste zu Batchen.
zum Code:
@echo off &setlocal
set "sourceRoot=.\von\"
set "sourceList=.\liste.txt"
set "destFolder=.\nach"
for /f "delims=" %%i in ('dir /a-d /b /s "%sourceRoot%\*.jpg"^|findstr /ig:"%sourceList%"') do (copy "%%~i" "%destFolder%\")
PAUSE
Dieser Code funktioniert sogar ziemlich gut, ABER es werden Schnittmengen mitkopiert. z.b brauch ich NUR die Nummer 11.jpg,.....aber es werden alle Bilder mit 11 als Schnittmenge mit kopiert.
Was müsste ich an dem Code ändern damit ich die Exakten Bilder nach der Liste kopiere ?
Vielen Dank im Voraus
Ich muss gewisse Bilder aus einem riesiegen Verzeichnis batchen.
Die Bilder sind (zufällig) Durchnummeriert:
12351234.jpg
12462345.jpg
2351.jpg
2351223.jpg
Mit einem Code hab ich es geschafft die Bennenungen der Bilder mit Hilfe einer Liste zu Batchen.
zum Code:
@echo off &setlocal
set "sourceRoot=.\von\"
set "sourceList=.\liste.txt"
set "destFolder=.\nach"
for /f "delims=" %%i in ('dir /a-d /b /s "%sourceRoot%\*.jpg"^|findstr /ig:"%sourceList%"') do (copy "%%~i" "%destFolder%\")
PAUSE
Dieser Code funktioniert sogar ziemlich gut, ABER es werden Schnittmengen mitkopiert. z.b brauch ich NUR die Nummer 11.jpg,.....aber es werden alle Bilder mit 11 als Schnittmenge mit kopiert.
Was müsste ich an dem Code ändern damit ich die Exakten Bilder nach der Liste kopiere ?
Vielen Dank im Voraus
Please also mark the comments that contributed to the solution of the article
Content-Key: 309096
Url: https://administrator.de/contentid/309096
Printed on: April 25, 2024 at 02:04 o'clock
3 Comments
Latest comment
Hi.
Add a leading backslash "\" to all your lines in the source text file. Then modify the parameters for findstr:
Or you can also use powershell to do this:
Regards
Add a leading backslash "\" to all your lines in the source text file. Then modify the parameters for findstr:
findstr /ELIG:"%sourcelist%"
@echo off
powershell -Executionpolicy ByPass -Command "$list = gc 'C:\liste.txt'; gci 'C:\von' -Recurse -File | ?{$_.Name -in $list} | copy-item -Destination 'C:\nach'"
The second too ! For those who are using at least powershell 3.0 man.
I'm to lazy writing ?{!$_.PsIscontainer } instead of using the -file parameter only for those PS 2.0 bitches out there...
You batchies still drive a "Käfer" in 30 years and don't know the "power of the shell".
I'm to lazy writing ?{!$_.PsIscontainer } instead of using the -file parameter only for those PS 2.0 bitches out there...
You batchies still drive a "Käfer" in 30 years and don't know the "power of the shell".