Home

Detect File Attribute for files on demand (PINNED/UNPINNED)

%3CLINGO-SUB%20id%3D%22lingo-sub-159895%22%20slang%3D%22en-US%22%3EDetect%20File%20Attribute%20for%20files%20on%20demand%20(PINNED%2FUNPINNED)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-159895%22%20slang%3D%22en-US%22%3E%3CP%3EWe%20try%20to%20work%20with%20the%20attributes%20of%20files%20in%20OneDrive%20for%20Business%20on%26nbsp%3BWindows%2010%20(1709).%20This%20article%20ha%20a%20great%20overview%3A%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fwww.petri.com%2Fmanaging-onedrive-files-demand-windows-10-fall-creators-update%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.petri.com%2Fmanaging-onedrive-files-demand-windows-10-fall-creators-update%3C%2FA%3E%3C%2FP%3E%0A%3CP%3EThis%20is%20a%20link%20that%20documents%20the%26nbsp%3Battributes%20flags%3A%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fwindows%2Fdesktop%2Fgg258117(v%3Dvs.85).aspx%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fwindows%2Fdesktop%2Fgg258117(v%3Dvs.85).aspx%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20don't%20find%20an%20exact%20representation%20of%20the%20pinned%20and%20unpinned%26nbsp%3Battribute%3A%3C%2FP%3E%0A%3CP%3EC%3A%5CUsers%5Cmarcoscheel%5COneDrive%20-%20Gl%C3%BCck%20%26amp%3B%20Kanja%20Consulting%20AG%5CTransfer%26gt%3B%20attrib%20%2F%3F%3CBR%20%2F%3EDisplays%20or%20changes%20file%20attributes.%3C%2FP%3E%0A%3CP%3EATTRIB%20%5B%2BR%20%7C%20-R%5D%20%5B%2BA%20%7C%20-A%5D%20%5B%2BS%20%7C%20-S%5D%20%5B%2BH%20%7C%20-H%5D%20%5B%2BO%20%7C%20-O%5D%20%5B%2BI%20%7C%20-I%5D%20%5B%2BX%20%7C%20-X%5D%20%5B%2BP%20%7C%20-P%5D%20%5B%2BU%20%7C%20-U%5D%3CBR%20%2F%3E%20%5Bdrive%3A%5D%5Bpath%5D%5Bfilename%5D%20%5B%2FS%20%5B%2FD%5D%5D%20%5B%2FL%5D%3C%2FP%3E%0A%3CP%3E%2B%20Sets%20an%20attribute.%3CBR%20%2F%3E%20-%20Clears%20an%20attribute.%3CBR%20%2F%3E%20R%20Read-only%20file%20attribute.%3CBR%20%2F%3E%20A%20Archive%20file%20attribute.%3CBR%20%2F%3E%20S%20System%20file%20attribute.%3CBR%20%2F%3E%20H%20Hidden%20file%20attribute.%3CBR%20%2F%3E%20O%20Offline%20attribute.%3CBR%20%2F%3E%20I%20Not%20content%20indexed%20file%20attribute.%3CBR%20%2F%3E%20X%20No%20scrub%20file%20attribute.%3CBR%20%2F%3E%20V%20Integrity%20attribute.%3CBR%20%2F%3E%20%3CSTRONG%3EP%20Pinned%20attribute.%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3E%20U%20Unpinned%20attribute.%3C%2FSTRONG%3E%3CBR%20%2F%3E%20B%20SMR%20Blob%20attribute.%3CBR%20%2F%3E%20%5Bdrive%3A%5D%5Bpath%5D%5Bfilename%5D%3CBR%20%2F%3E%20Specifies%20a%20file%20or%20files%20for%20attrib%20to%20process.%3CBR%20%2F%3E%20%2FS%20Processes%20matching%20files%20in%20the%20current%20folder%3CBR%20%2F%3E%20and%20all%20subfolders.%3CBR%20%2F%3E%20%2FD%20Processes%20folders%20as%20well.%3CBR%20%2F%3E%20%2FL%20Work%20on%20the%20attributes%20of%20the%20Symbolic%20Link%20versus%3CBR%20%2F%3E%20the%20target%20of%20the%20Symbolic%20Link%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20want%20to%20interact%20with%20the%20files%20in%20C%20and%2For%20C%23.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20is%20a%20sample%20directory%20with%20files%20and%20the%20three%20states%3A%26nbsp%3B%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20760px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F28707i17211139597EF164%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22screen.png%22%20title%3D%22screen.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EThis%20is%20a%20LS%20on%20a%20folder%20with%20different%20files%3C%2FP%3E%0A%3CDIV%3EDirectory%3A%20C%3A%5CUsers%5Cmarcoscheel%5COneDrive%20-%20Gl%C3%BCck%20%26amp%3B%20Kanja%20Consulting%20AG%5CTransfer%3C%2FDIV%3E%0A%3CDIV%3EMode%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20LastWriteTime%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Length%20Name%3CBR%20%2F%3E----%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20-------------%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20------%20----%3CBR%20%2F%3E-----l%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%3CSPAN%3EXX.XX.XXX%3C%2FSPAN%3E%20%26nbsp%3B%20%26nbsp%3B%2011%3A09%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%205386058%20o365api.pbix%3CBR%20%2F%3E-----l%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%3CSPAN%3EXX.XX.XXX%3C%2FSPAN%3E%20%26nbsp%3B%20%26nbsp%3B%2021%3A25%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%2018325%20test.docx%3CBR%20%2F%3E-----l%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3BXX.XX.XXX%2016%3A25%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20(3631219)%20When-To-Use-What-In-Office-365.pdf%3C%2FDIV%3E%0A%3CDIV%3EThis%20is%20the%20attribute%20as%20an%20int%3A%3C%2FDIV%3E%0A%3CDIV%3EC%3A%5CUsers%5Cmarcoscheel%5COneDrive%20-%20Gl%C3%BCck%20%26amp%3B%20Kanja%20Consulting%20AG%5CTransfer%26gt%3B%20get-item%20*.*%20%7C%20%25%20%7B%20%24_.Attributes%20%7D%3CBR%20%2F%3EReparsePoint%3CBR%20%2F%3E525312%3CBR%20%2F%3E4199936%3C%2FDIV%3E%0A%3CDIV%3EC%3A%5CUsers%5Cmarcoscheel%5COneDrive%20-%20Gl%C3%BCck%20%26amp%3B%20Kanja%20Consulting%20AG%5CTransfer%26gt%3B%20get-item%20*.*%20%7C%20%25%20%7B%20%5Bint%5D%24_.Attributes%20%7D%3CBR%20%2F%3E1024%3CBR%20%2F%3E525312%3CBR%20%2F%3E4199936%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CDIV%3EThe%20system%20is%20capable%20to%20represent%20the%20cloud%20only%20file%20as%20a%20ReparsePoint%2C%20but%26nbsp%3Bthe%20pinned%20and%20unpinned%20file%20are%20not%20matched.%20Is%20there%20an%20offical%20documentation%26nbsp%3Bregarding%20these%26nbsp%3B%22missing%22%20flags.%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-159895%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EOneDrive%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Highlighted
Marco Scheel
Contributor

We try to work with the attributes of files in OneDrive for Business on Windows 10 (1709). This article ha a great overview:

https://www.petri.com/managing-onedrive-files-demand-windows-10-fall-creators-update

This is a link that documents the attributes flags:

https://msdn.microsoft.com/en-us/library/windows/desktop/gg258117(v=vs.85).aspx

 

I don't find an exact representation of the pinned and unpinned attribute:

C:\Users\marcoscheel\OneDrive - Glück & Kanja Consulting AG\Transfer> attrib /?
Displays or changes file attributes.

ATTRIB [+R | -R] [+A | -A] [+S | -S] [+H | -H] [+O | -O] [+I | -I] [+X | -X] [+P | -P] [+U | -U]
[drive:][path][filename] [/S [/D]] [/L]

+ Sets an attribute.
- Clears an attribute.
R Read-only file attribute.
A Archive file attribute.
S System file attribute.
H Hidden file attribute.
O Offline attribute.
I Not content indexed file attribute.
X No scrub file attribute.
V Integrity attribute.
P Pinned attribute.
U Unpinned attribute.
B SMR Blob attribute.
[drive:][path][filename]
Specifies a file or files for attrib to process.
/S Processes matching files in the current folder
and all subfolders.
/D Processes folders as well.
/L Work on the attributes of the Symbolic Link versus
the target of the Symbolic Link

 

We want to interact with the files in C and/or C#.

 

This is a sample directory with files and the three states: screen.png

This is a LS on a folder with different files

Directory: C:\Users\marcoscheel\OneDrive - Glück & Kanja Consulting AG\Transfer
Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-----l      XX.XX.XXX     11:09        5386058 o365api.pbix
-----l      XX.XX.XXX     21:25          18325 test.docx
-----l       XX.XX.XXX 16:25      (3631219) When-To-Use-What-In-Office-365.pdf
This is the attribute as an int:
C:\Users\marcoscheel\OneDrive - Glück & Kanja Consulting AG\Transfer> get-item *.* | % { $_.Attributes }
ReparsePoint
525312
4199936
C:\Users\marcoscheel\OneDrive - Glück & Kanja Consulting AG\Transfer> get-item *.* | % { [int]$_.Attributes }
1024
525312
4199936
 
The system is capable to represent the cloud only file as a ReparsePoint, but the pinned and unpinned file are not matched. Is there an offical documentation regarding these "missing" flags.