This is important, because OneDrive uses the file attribute Pinned (Pinned = 0x00080000) for file 'availability' (green checkmark is filled or unfilled in Windows Explorer).
Note that when Windows Explorer is used to rename the file, the Pinned file attribute is preserved.
::Display WIndows 1909 version.
C:\xx>ver
Microsoft Windows [Version 10.0.18363.657]
C:\xx>echo > junk.bak
C:\xx>attrib *
A C:\xx\junk.bak
C:\xx>attrib * +P
C:\xx>attrib *
A P C:\xx\junk.bak
::Switch to Total Commander to rename the file to junk.txt (use either SHIFT+F6 or the Mult-Rename tool)
::note the P attribute is no longer set
C:\xx>attrib *
A C:\xx\junk.txt
::Set the P attribute again
C:\xx>attrib * +p
C:\xx>attrib *
A P C:\xx\junk.txt
::Switch to Windows Explorer to rename the file 'junk.txt' to 'junk.bak' (use F2 or right click Rename)
::note that the P attribute is preserved
C:\xx>attrib *
A P C:\xx\junk.bak
Rename (Shift+F6) unsets file attribute Pinned (used by OneDrive, Always keep on this device)
Moderators: Hacker, petermad, Stefan2, white
- ghisler(Author)
- Site Admin
- Posts: 50532
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Re: Rename (Shift+F6) unsets file attribute Pinned (used by OneDrive, Always keep on this device)
I need more information:
1. What do you mean with "pinned"? Do you mean "offline only"? I ask because 0x80000 is not described by Microsoft:
https://docs.microsoft.com/de-de/windows/win32/fileio/file-attribute-constants
2. When a file has at least one of the attributes "read only", "hidden", or "system", Total Commander calls SetFileAttributes(name,FILE_ATTRIBUTE_ARCHIVE) because otherwise rename would fail. Does the file have one of these set?
3. When none of these is set, Total Commander calls directly MoveFileEx.
4. In my tests, renaming a file which is only available online doesn't get available when renaming it, whether it has read only set or not
1. What do you mean with "pinned"? Do you mean "offline only"? I ask because 0x80000 is not described by Microsoft:
https://docs.microsoft.com/de-de/windows/win32/fileio/file-attribute-constants
2. When a file has at least one of the attributes "read only", "hidden", or "system", Total Commander calls SetFileAttributes(name,FILE_ATTRIBUTE_ARCHIVE) because otherwise rename would fail. Does the file have one of these set?
3. When none of these is set, Total Commander calls directly MoveFileEx.
4. In my tests, renaming a file which is only available online doesn't get available when renaming it, whether it has read only set or not
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
Re: Rename (Shift+F6) unsets file attribute Pinned (used by OneDrive, Always keep on this device)
Thanks for looking into this.
Sorry to be so circular, but by PINNED I mean the PINNED file attribute is set.
I think Microsoft OneDrive uses the PINNED file attribute to consider a file 'always available', that is:
Here are some sites I found when doing a web search for file attribute pinned.
Comment from the 7zip developer, Igor Pavlov about it:
https://sourceforge.net/p/p7zip/bugs/200
Comment (dated Jan 20 '18), says it's in a version of winnt.h. Also a comment above it says the latest SDK headers have it.
https://superuser.com/questions/1214542/what-do-new-windows-8-10-attributes-mean-no-scrub-file-x-integrity-v-pinn
(in German) shows the various icons displayed by Windows File Explorer depending on the file attribute pinned setting and how it is used in Microsoft OneDrive:
https://hansbrender.com/2017/12/29/files-on-demand-der-umgang-mit-den-drei-status-teil-2
Here's a DOS CMD session using the DOS commands ATTRIB and REN showing that the file attribute PINNED is preserved.
Here is what I see after I use Total Commander to rename file 'junk.txt' to 'junk.bak' (The PINNED attribute is no longer set.):
My guess is that the Microsoft REN command is using an undocumented/poorly documented feature.
Sorry to be so circular, but by PINNED I mean the PINNED file attribute is set.
I think Microsoft OneDrive uses the PINNED file attribute to consider a file 'always available', that is:
- both locally on disk and in the cloud
- Windows File Explorer shows a solid green checkmark for the file Status
Code: Select all
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
Comment from the 7zip developer, Igor Pavlov about it:
https://sourceforge.net/p/p7zip/bugs/200
Comment (dated Jan 20 '18), says it's in a version of winnt.h. Also a comment above it says the latest SDK headers have it.
https://superuser.com/questions/1214542/what-do-new-windows-8-10-attributes-mean-no-scrub-file-x-integrity-v-pinn
(in German) shows the various icons displayed by Windows File Explorer depending on the file attribute pinned setting and how it is used in Microsoft OneDrive:
https://hansbrender.com/2017/12/29/files-on-demand-der-umgang-mit-den-drei-status-teil-2
Here's a DOS CMD session using the DOS commands ATTRIB and REN showing that the file attribute PINNED is preserved.
Code: Select all
c:\>cd xx
c:\xx>attrib *
A C:\xx\junk.bak
c:\xx>attrib * +P
c:\xx>attrib *
A P C:\xx\junk.bak
c:\xx>ren junk.bak junk.txt
c:\xx>attrib *
A P C:\xx\junk.txt
Code: Select all
c:\xx>attrib *
A C:\xx\junk.bak
Re: Rename (Shift+F6) unsets file attribute Pinned (used by OneDrive, Always keep on this device)
BTW, a similar bug with Not Content Indexed attribute being lost after rename has been fixed in Total Commander 9.50 beta 1: viewtopic.php?f=28&t=52897
Donate for Ukraine to help stop Russian invasion!
Ukraine's National Bank special bank account:
UA843000010000000047330992708
Ukraine's National Bank special bank account:
UA843000010000000047330992708
- ghisler(Author)
- Site Admin
- Posts: 50532
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
Re: Rename (Shift+F6) unsets file attribute Pinned (used by OneDrive, Always keep on this device)
I see - apparently it's for the option "Always keep on this device" in the context menu. I could reproduce the problem and found a solution.
It's very unfortunate that this flag isn't documented, it would allow me to show a special overlay icon for "always kept" files.
It's very unfortunate that this flag isn't documented, it would allow me to show a special overlay icon for "always kept" files.
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
Re: Rename (Shift+F6) unsets file attribute Pinned (used by OneDrive, Always keep on this device)
I can verify that this is fixed in TC 9.5 RC2.