sagula91
Goto Top

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

Content-Key: 309096

Url: https://administrator.de/contentid/309096

Printed on: April 25, 2024 at 02:04 o'clock

Mitglied: 129813
Solution 129813 Jul 08, 2016 updated at 10:47:17 (UTC)
Goto Top
Hi.
Add a leading backslash "\" to all your lines in the source text file. Then modify the parameters for findstr:
findstr /ELIG:"%sourcelist%"
Or you can also use powershell to do this:
@echo off
powershell -Executionpolicy ByPass -Command "$list = gc 'C:\liste.txt'; gci 'C:\von' -Recurse -File | ?{$_.Name -in $list} | copy-item -Destination 'C:\nach'"  
Regards
Member: sagula91
sagula91 Jul 08, 2016 at 19:40:49 (UTC)
Goto Top
Thanks a lot for your quick response !

The first method you mentioned works fine....
Mitglied: 129813
129813 Jul 08, 2016 updated at 20:51:51 (UTC)
Goto Top
Zitat von @sagula91:
The first method you mentioned works fine....
The second too face-smile ! For those who are using at least powershell 3.0 man.
I'm to lazy writing ?{!$_.PsIscontainer } instead of using the -file parameter face-big-smile only for those PS 2.0 bitches out there...

You batchies still drive a "Käfer" in 30 years face-big-smile face-big-smile and don't know the "power of the shell".