In tips 0494, 3579, and 3580, I parsed a file batch parameter.

The %~a1 syntax will return the attributes of file %1. If %1 was C:\Boot.ini, %~a1 would normally display -r-hs----.

I have scripted GetAttributes.bat to return a call directed environment variable with the attributes of %1, without the -.

The syntax for using GetAttributes.bat is:

Call GetAttributes.bat FileName Attributes

Where FileName is the fully qualified name of a file, and Attributes is the name of the variable you want set.

GetAttributes.bat contains:

@echo off                              if \{%2\}==\{\} @echo Syntax: Call GetAttributes FileName Attributes&goto :EOF                              set %2=                              if not exist %1 @echo File %1 not found.&goto :EOF                              setlocal                              set filename=%1                              set attr=%~a1                              set attr=%attr:-=%                              endlocal&set %2=%attr%