Dies sollte die Arbeit erledigen:
@ECHO OFF SETLOCAL EnableDelayedExpansion REM ************************************************** SET source_dir=C:\folder1 SET target_dir=C:\folder2 SET wildcard=obsolete REM ************************************************** FOR /D /R %%G IN ("%source_dir%") DO ( SET "folder_name=%%G" ECHO !folder_name! | FINDSTR /R "%wildcard%" >nul && CALL :copy ) ECHO. & ECHO. & ECHO. & ECHO. & ECHO. & ECHO Done^^! PAUSE EXIT :copy SET target_folder_name=!folder_name:%source_dir%\=! SET endbit=!target_folder_name:*%wildcard%=! SET target_folder_name=!target_folder_name:%endbit%=! SET endbit=!folder_name:*%wildcard%=! SET folder_name=!folder_name:%endbit%=! ROBOCOPY "!folder_name!" "%target_dir%\!target_folder_name!" /E EXIT /B
Die wildcard
Groß- und Kleinschreibung wird berücksichtigt, es sei denn, Sie fügen die /I
Option hinzu FINDSTR
:
ECHO !folder_name! | FINDSTR /I /R "%wildcard%" >nul && CALL :copy