Windows Batch

Read from "folderlist.txt" file line by line process

folderlist.txt
abc
def

backup.bat
@echo off

set timestamp=%date:~10,4%%date:~7,2%%date:~4,2%

ECHO Archive Start %time% > D:\Backup_Astute_TillServer\log\Archive.log 

cd D:\Backup_Astute_TillServer
for /F %%A in (folderlist.txt) do (
   cd %%A
REM Check whether the program has already run today
IF not exist %timestamp%.zip (
mkdir %timestamp%
robocopy /mov "C:\Astute\TillServer\%%A\Sales" "D:\Backup_Astute_TillServer\%%A\%timestamp%"  /minage:7 "*.processed" 

IF %ERRORLEVEL% ==0 (
for /d %%x in (*) do "C:\Program Files (x86)\7-Zip\7z.exe" a "%%x.zip" "%%x\"
rd %timestamp% /q /s
ECHO %%A Archive Finish %time% >> D:\Backup_Astute_TillServer\log\Archive.log 
) ELSE (
ECHO %%A Robocopy Failed %time% >> D:\Backup_Astute_TillServer\log\Archive.log 
)
) ELSE (
ECHO %%A Archive has already run today! %time% >> D:\Backup_Astute_TillServer\log\Archive.log 
)
cd ..
)

Comments

Popular posts from this blog

Nginx Proxy & Load Balance & LNMP

Snort+barnyard2+Snorby CentOS 6.5_64 Installation

ORACLE Error