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
DEL "%DESTINATION%\*" /Q
XCOPY "%SOURCE%\%last_dir%\*" "%DESTINATION%" /S /E
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..