Batch-Datei für automatisches Kopieren von Dateien mit Ausnahmen?

Hallo! Ich möchte einen automatischen Kopiervorgang mittels einer *bat-Datei anstoßen. Das wäre ja nicht kompliziert. Allerdings sollen davon Dateien mit einer bestimmten Teilbezeichnung ausgenommen sein, also z. B. alle Dateien, die die Buchstaben “CWL” im Dateinamen tragen.

Wie kann ich das umsetzen?

(1 votes)
Loading...

Similar Posts

Subscribe
Notify of
6 Answers
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
merkurus
1 month ago

Can be done with ROBOCOPY. So e.g.

robocopy E:\Ordner1\ E:\Ordner2\ /xf *CWL*.*

robocopy E:\Ordner1\ E:\Ordner2\ /s /xf *CWL*.*

Parameters /s if subdirectories

/xf closes corresponding files

merkurus
1 month ago

Yeah, right. If you set quotation marks, you must not put \.
What is important for folders with spaces.
If you don’t set any quotation marks, then it would work.
I just noticed.

Neeuugiieerriig
1 month ago

Example:

@echo off
set "source=C:\Pfad\zum\Quellordner"
set "destination=C:\Pfad\zum\Zielordner"

if not exist "%destination%" mkdir "%destination%"

for %%F in (%source%\*) do (
    echo %%~nxF | find /I "CWL" >nul
    if errorlevel 1 (
        copy "%%F" "%destination%"
    )
)