Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
Squashman
- Expert
- Posts: 4486
- Joined: 23 Dec 2011 13:59
#1
Post
by Squashman » 05 Jan 2015 15:51
I have seen this question asked several times. And Dave even updated his post on
SO last month.
How did none of us ever see this?
http://ss64.com/nt/syntax-args.htmlUse %~a1 to display the Extended Attributes of a file.
FOR's %%~aI recognizes 9 NTFS file attributes. The expansion of a file attribute produces a series of 9 dashes, with each recognized attribute replacing a dash with a letter. A file with no recognized attributes or with none set will expand to 9 dashes like this: ---------
Attribute Expansion
FILE_ATTRIBUTE_DIRECTORY d--------
FILE_ATTRIBUTE_READONLY -r-------
FILE_ATTRIBUTE_ARCHIVE --a------
FILE_ATTRIBUTE_HIDDEN ---h-----
FILE_ATTRIBUTE_SYSTEM ----s----
FILE_ATTRIBUTE_COMPRESSED -----c---
FILE_ATTRIBUTE_OFFLINE ------o--
FILE_ATTRIBUTE_TEMPORARY -------t-
FILE_ATTRIBUTE_REPARSE_POINT --------l
FILE_ATTRIBUTE_NORMAL ---------
-
penpen
- Expert
- Posts: 2009
- Joined: 23 Jun 2013 06:15
- Location: Germany
#2
Post
by penpen » 05 Jan 2015 19:31
Squashman wrote:How did none of us ever see this?
I knew and used it, and i'm sure i wasn't the only one, although i didn't read it on ss64; for example see:
-
http://www.dostips.com/forum/viewtopic.php?p=28311#p28311 just search for "%%~at"
-
http://www.dostips.com/forum/viewtopic.php?p=27548#p27548 just search for "arg=%%~ac"
I only missed, that you were looking for something like that.
penpen
Edit: I'm not sure but I think, i've seen such a table somewhere within the MS C++ documentation, but i can't find it (the names used above are defined in "win32.h").
Last edited by
penpen on 06 Jan 2015 10:42, edited 2 times in total.
-
Squashman
- Expert
- Posts: 4486
- Joined: 23 Dec 2011 13:59
#3
Post
by Squashman » 05 Jan 2015 20:13
You would think the "a" parameter would be documented in the help for CMD.exe or the FOR command. I can't find it documented in any of the help.
-
npocmaka_
- Posts: 516
- Joined: 24 Jun 2013 17:10
- Location: Bulgaria
-
Contact:
#6
Post
by npocmaka_ » 06 Jan 2015 04:15
will this if exist %1\ work on FAT32 (I have a memory that it will not , but I'm not sure)?
Also file attributes on ss64 are pointed as NTFS file attributes.
-
trebor68
- Posts: 146
- Joined: 01 Jul 2011 08:47
#7
Post
by trebor68 » 08 Jan 2015 20:07
Please see more informations:
CALL /?Here a small batch file:
Code: Select all
@echo off
setlocal
:: echo %1 %~a1
set test=%~a1
set test=%test:~0,1%
if %test%==d (echo %1 is a directory) else echo %1 is not a directory
Tested in Win7.
Here some examples:
Code: Select all
D:\CMDVerz>exattr InRegEx5.bat
InRegEx5.bat is not a directory
D:\CMDVerz>exattr UniCode
UniCode is a directory
D:\CMDVerz>exattr "findstr info.txt"
"findstr info.txt" is not a directory