Solved How to copy the Latest Modified folder using DOS commands?

April 25, 2016 at 12:01:30
Specs: Windows 12
Please help me on the this issue. I would like to copy latest modified directory from multiple folders in server, this directory will be having subdirectories. After copying, Script needs to create the new folder.But issue is when i am running the script, it is looking into the newly created folder, It should not go for newly created folder, it should copy the newly modified folder.

For example: I am having three folders namely A, B, C.. In which C is newly modified, at first time am running the script content from the C folder is copied correctly, also Fourth folder D is created.
Again second time am running the script, only C is the newly modified folder, D is not modified it is newly created, so C folder should copy when i am running the script. I am using the below script.

DIR "%SOURCE%" /B /AD /O-D /TA > "%TEMP%\dirlist.tmp"
< "%TEMP%\dirlist.tmp" SET /P last_dir=

FOR /D %%I IN ("%DESTINATION%\*") DO RD "%%I" /S /Q

XCOPY "%SOURCE%\%last_dir%\*" "%DESTINATION%" /S /E

mkdir comparison_folder

In "dir" command I have tried to use /TA and /TW switches at copy only latest modified folder, But i am not able to do. Please help me on this issue..

Thank you!!

See More: How to copy the Latest Modified folder using DOS commands?

Report •

April 26, 2016 at 05:38:03
Sorry, OS is Windows 7

Report •

April 26, 2016 at 15:39:34
✔ Best Answer
I'm not entirely sure what you're going for, but it sounds like ROBOCOPY would do what you want.

How To Ask Questions The Smart Way

Report •
Related Solutions

Ask Question