how to get today's modified folders in a direc

2019-03-05 02:48发布

I have a folder "Projects" and it contains multiple folders for different projects in it, I want to back-up that folder which has some modifications today( it can be single project or can be more than one).

set ProjectFolder=D:\Projects    

for %%o IN (%ProjectFolder%/*.*) DO (
 echo %%o 
 set Project1Folder=%%o
 xcopy "%Project1Folder%\*.*" "%NetworkFolder%\%Project1Folder%\backup_%CurrentDate%\" /s/h/e/k/f/c 
)

And how to pass foldername(modified project) to be be copied in a loop.

Note :- trying something like below but how to get today's modified folder(s) only..

EDIT:-

set MainFolder=D:\Projects          
set LocalFolder=D:\backup

for /d %%D in (%MainFolder%/*.*) do (  
set ProjectFolder=%%~fD
xcopy "%%~fD\*.*" "%LocalFolder%\" /s/h/e/k/f/c /D:03-23-2018
)   

Edit2:-

for /D %%A in ("%LocalFolder%\*") do (
 echo %%~fA
for /F %%N in ('forfiles /S /P %%~fA /M "*" /D +0 /C "cmd /C if @isdir==FALSE echo _" ^| find /C "_"') do set "NUMBER=%%N"
echo %NUMBER%
if %%N GTR 0 xcopy "%%~fA\*.*" "%LocalFolder%\" /s/e/k/f/c
 )

0条回答
登录 后发表回答