another way... using Conditional Execution and findstr
attrib "%file%"|findstr /b "A"&&set Archive_Status=A
http://www.ss64.com/bashsy
Main Topics
Browse All TopicsI 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?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
another way... using Conditional Execution and findstr
attrib "%file%"|findstr /b "A"&&set Archive_Status=A
http://www.ss64.com/bashsy
Business Accounts
Answer for Membership
by: Shift-3Posted on 2008-05-22 at 12:38:10ID: 21626898
You can do this by using the FOR command to loop through the output of ATTRIB and set the Archive_Status variable to the first item on the line. If the Archive attribute is set then this will be an A.
_cmd.html
See here for more information on FOR /F:
http://www.ss64.com/nt/for
Select allOpen in new window