rsync
rsync
is a tools available for windows too, normally used to remote synchronize directory... but it works fine on local directory too... as stated in its own description
a fast, versatile, remote (and local) file-copying tool
From this answer on unix.stackexchange...
rsync -a --prune-empty-dirs --include '*/' --include '*.txt' --exclude '*' source/ target/
Note that it exists an option to delete the files from the origin that you can include in the command line, I think the one you search for is --remove-source-files
, but check it carefully. Another option you may find useful is -n
-n, --dry-run perform a trial run with no changes made
--remove-source-files sender removes synchronized files (non-dir)
find
find
is another tool you can find in your bash
shell under windows as well as a compiled executable(gnu findutils)...
The following line works under Linux but you can modify the cp
statement to be compliant with your system specifications. From another answer...
find . -name '*.txt' -exec cp --parents \{\} /target \;
Windows equivalent of find
From another quesiton/answer for your batch script you may use this hints...
dir <drive: [drive:]> /s | findstr /i <pattern>
... of course if they felt the need to do a powershell it is reasonable to expect that in that environment there should be a more simple way to do it...
but maybe the following one is an enough simple starting point for your script:
dir c:\foo /s *.txt