I want to copy all 2 level down subfolders and their entire contents into another folder, preserving everything, structure etc. but only from a certain date of file / folders forward
e.g. I have
…108600**
I want to exclude “…108600*” and move all “…108600**” elsewhere
ChatGPT’s suggestion doesn’t work, not quite ready to take over some jobs 🙂
xcopy "C:SourceFolder**" "C:DestinationFolder" /E /I
The above throws this error:
File not found - *
0 File(s) copied
Probably the same reason this fails as well (also from ChatGPT :), can’t see the error message if any, nor does any copying occur:
@echo off
set source="...108600"
set destination="..._temp"
for /d %%i in ("%source%**") do (
xcopy "%%i" "%destination%" /E /I
)
pause
I believe ChatGPT understood my question since it gives me this answer bundled for mac/linux:
find /path/to/source -mindepth 2 -maxdepth 2 -type d -exec cp -r {} /path/to/destination/ ;
however I need it on Windows and no clue whether that’s suppose to work at all, but “-mindepth 2” sounds like what I’m looking for
I had trouble googling anything to fix this (which is why ChatGPT failed as well I guess).
If I use robocopy’s /lev:7 (paths are 7 levels deep), it copies from the directories from source as well, and that accomplishes nothing, plus I need xcopy’s /d:17-1-2025 flag (files and folders changed since that date), not robocopy’s /MAXAGE:1 which produces the wrong result for some reason as well. Unlike xcopy, robocopy’s help seems ambiguous and confusing to me
Closest I came is with this:
for /D %%A in ("...108600*") do (
for /D %%B in ("%%~fA*") do (
xcopy /e /i /d:01-17-2025 "%%~fB*.*" "..._temp"
)
)
pause
source, comments on: https://stackoverflow.com/questions/32129482/copy-files-from-first-level-subfolder-only-to-another-location
however xcopy’s date flag failed too and instead it copies (almost) everything, so it’s a double failure at that alone…
Any suggestions? Just curious at this point 😀 I seem to remember having other software that did it but can’t find it again if it ever existed. Thank you