问题
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
)
来源:https://stackoverflow.com/questions/49448609/how-to-get-todays-modified-folders-in-a-directory-using-batch-file