I am trying to write a batch file to perform several maintenance tasks on some VMWare virtual disks. These tasks are destructive and I only want them to run after confirming the VM files were successfully backed up.
I am trying to use the ATTRIB command to return the value of the archive bit of a file (MyDisk.VMX). If the value is "A" (i.e. set) then I want the batch file to terminate. If the archive bit value is clear, then the maintenance task can run.
I have done Internet searches with every type of wording, but I can't find any batch file syntax that will let me query for archive bit value and use the returned value in an IF-THEN / IF-ELSE subroutine.
The attached code snippet shows what I'm trying to do. Right now I am only dumping to a log file just to see what the value is, but it is just treating it like a string. Any ideas? Can this even be done in a batch file?
set Archive_Status=ATTRIB MyDisk.VMX
echo Batch command: %0 %* >%logfile%
echo Started at %date% %time% >>%logfile%
echo ------------------------ >>%logfile%
ECHO %Archive_Status% >>%logfile%