XCOPY is designed to work with exclude lists ... See below:
dir /b /ad "source"|findstr /b "aaa" >"%temp%\aaafiles.tmp" xcopy "source" "destination\" /exclude:%temp%\aaafiles.tmp /y
The first line executes the DIR (directory) list of the source folder, listing the files in bare format ( / b ), ignoring the directory names ( / ad ). The output is sent to the FINDSTR command.
FINDSTR looks at each file name and compares its beginning ( / b ) with the string "aaa".
If the beginning of the file name matches the string "aaa", the file name is redirected (written) to the aaafiles.tmp file in the TEMP directory.
/ b is vital because you do not want to exclude files such as theaaafile.txt.
The XCOPY command copies files from the source folder to the destination folder, except for the files listed in the aaafiles.tmp file.
The request to overwrite existing files ( / y ) is disabled.
source and destination must be replaced with your own names.
Paul tasi
source share