I am writing a batch file that zips up MS Access 2010 files (file extension .accdb), renames the zip file with the date and time, then moves the zip file to a subfolder called Backups. The following shows the code so far:
@echo off
"C:\Program Files\VMware\VMware Tools\zip.exe" backup.zip *.accdb
for /f "tokens=1-5 delims=/ " %%d in ("%DATE%") do (set thedate=%%g-%%e-%%f)
for /f "tokens=1-3 delims=/:" %%a in ("%TIME:~0,8%") do (set thetime=%%a-%%b-%%c)
set thetime=%thetime: =0%
rename backup.zip %thedate%_%thetime%.zip
move %thedate%_%thetime%.zip .\Backups
%SystemRoot%\explorer.exe .\Backups
This is working fine. However, I'd like to add a check at the beginning to see if there are any users with open Access files (occurs if there are *.laccdb files) prior to performing the zip operation. The desired logic is:
- check if there are any *.laccdb files
- if there is/are *.laccdb file/s then send user a message to close Access files and abort batch file
- if no *.laccdb files are found then proceed with the zip operation (as written in the code above)
How do I add this IF/THEN/ELSE type logic to the batch file and how do I check for *.laccdb files?