copy folder with latest time stamp using batch file
Posted: 20 Feb 2020 09:58
Hello,
I am a new user trying to create batch files for the first time. I am trying to create a batch file that will detect the folder with the latest time stamp, copy the entire folder and sub folders and paste into another folder. The batch file will run everyday as new folders are added on a daily basis.
I have been using the code below but it only copies the file with the latest time stamp and not the folder. Any help would be appreciated. Thanks!
@echo off
setlocal enabledelayedexpansion
set "source=\\network_path\test"
set "dest= \\network_path\test2"
pushd "%source%"
for /f "tokens=*" %%G in ('dir *.* /b /a:d /o:d') do SET newest=%%G
copy "!newest!" "%dest%"
popd
cmd /k
I am a new user trying to create batch files for the first time. I am trying to create a batch file that will detect the folder with the latest time stamp, copy the entire folder and sub folders and paste into another folder. The batch file will run everyday as new folders are added on a daily basis.
I have been using the code below but it only copies the file with the latest time stamp and not the folder. Any help would be appreciated. Thanks!
@echo off
setlocal enabledelayedexpansion
set "source=\\network_path\test"
set "dest= \\network_path\test2"
pushd "%source%"
for /f "tokens=*" %%G in ('dir *.* /b /a:d /o:d') do SET newest=%%G
copy "!newest!" "%dest%"
popd
cmd /k