I am trying to write a script that copies all files in my source folder to another folder but without the folder structure, so just the files.
So far I have:
robocopy "<source>" "<target>" /s /copyall
Example: I have C:\1\2\3.txt and C:\4\5\6.jpg and in my target I only want D:\target\3.txt and D:\target\6.jpg
Any ideas?
Best Answer
As already stated in the comments, you can achieve this easily with Powershell:
This runs
Get-ChildItem
recursively, looking only for files matching the filter*.txt
. Afterwards the result is filtered by theLastAccessTime
attribute of the file and only files newer than date X are kept. The result of that is piped intoCopy-Item
.Of course, you can also run robocopy at the end, but that becomes pretty redundant.