I have a bunch of Excel Workbooks
that update periodically. I want to copy these files every Sunday to the folder created with current date in the name (eg Workbooks-28.06.2017
). I have written a batch script but it is not working.
What am I doing wrong?
Code:
@echo OFF
xcopy /s C:\Users\rerraboina\Desktop\tracker automation\Consolidation\test dynamic
for /f "skip=1" %%d in ('wmic os get localdatetime') do if not defined mydate set mydate=%%d
md %mydate:~0,8%
Here's an example:
archive.bat
@ ECHO OFF
PUSHD %~dp0
FOR /f "skip=1" %%d IN ('WMIC OS get LocalDateTime') DO IF NOT DEFINED myDate SET myDate=%%d
SET archiveDirName=Workbooks-%myDate:~0,8%
MD %archiveDirName%
XCOPY /S /I /Y "Excel Workbooks" %archiveDirName%\
POPD
"Excel Workbooks"
is an example folder which contains multiple subfolders having on *.xlsx
file in each.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.