You can generate a list of all systemfiles using the dir
command. So
dir /b /as > %USERPROFILE%\excluded_Files.txt
Would generate a list of the systemfiles from that directory.
Using xcopy as described here you can now copy all files from one directory to another excluding the systemfiles.
The xcopy command should be something like this:
xcopy C:\firstDirectory\*.txt C:\secondDirectory /EXCLUDE:%USERPROFILE%\excluded_Files.txt
Edit
So your code that is there would copy all rtf and txt files from the whole C drive to Drive D folder E.
A batch-file using my method would look like this:
@echo off
cd /d C:\
dir /b /as /s > %USERPROFILE%\excluded_Files.txt
xcopy C:\*.rtf D:\E /EXCLUDE:%USERPROFILE%\excluded_Files.txt /s
xcopy C:\*.txt D:\E /EXCLUDE:%USERPROFILE%\excluded_Files.txt /s
Explanation:
@echo off
supresses redundant output of the commands that would be displayed before execution.
cd /d C:\
changes the current execution directory to the root of the C drive. /d
is added for potential drive change.
dir /b /as /s > %USERPROFILE%\excluded_Files.txt
redirects the output of the dir command into a file in your userprofile (Usually C:\Users\yourUserName
). The switch /b
will only show the filenames and not size, creation date etc. /as
will only list system files and /s
makes the dir command work recursively through all directories.
xcopy C:\*.rtf D:\E /EXCLUDE:%USERPROFILE%\excluded_Files.txt /s
will copy all rtf files from C:\ to D:\E and exclude all files from the list previously created (that will contain all system txt and rtf files (as well as others)). /s
makes xcopy work recursively as for dir.
Next line is a copy of the same with txt files.