各位好,
下面的bat只能將C:\test\Backup\目錄下檔名固定是日期的自動備份
20190901.Zip
FOR /F "tokens=1-3 delims=/ " %%a IN ("%date%") DO (SET _today=%%a%%b%%c)
XCOPY "C:\test\Backup%_today%.zip" "E:\test Backup\DailyBackup" /K/E/Y/C/H
若每天C:\test\Backup\的目錄下都會產生今天的日期後面不同字的檔名,要怎麼自動備份至
E:\test Backup\DailyBackup\目錄下
如:
C:\test\Backup\20190901-123453.Zip
C:\test\Backup\20190902-123896.Zip
C:\test\Backup\20190903-12388596.Zip
複製所有檔名包含當日的zip檔到指定位置
e.g.
20190905-123.zip
20190905-456.zip
20190905-123.copy.zip
@echo off
for /F "tokens=1-3 delims=/ " %%a IN ("%date%") DO SET _today=%%a%%b%%c
for %%f in (C:\test\Backup\%_today%-*.zip) do (
XCOPY "%%f" "E:\test Backup\DailyBackup\" /K/E/Y/C/H/I
)
set dd=%date:~8,2%
set dm=%date:~5,2%
set dy=%date:~0,4%
set mydate=%dy%%dm%%dd%
path "C:\Program Files\7-Zip"
7z
7z a -tzip "D:\xxx\xxx_bak_%mydate%.zip" "D:\xxx"
試看看瞜!