NTLinks + NTLinksMaker: NTFS links creation and information

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

I also move documents, settings and other useful stuff to another partition, and restore links using such batch...
User avatar
byblo
Senior Member
Senior Member
Posts: 270
Joined: 2005-02-20, 21:13 UTC
Contact:

Post by *byblo »

Hello.

Is it possible to link files by their extension from a folder to another?

For instance, to link:

folder1\file1.bin
folder1\file2.bin

to -->

folder2\*.bin

Also, will new created in future *.bin will be linked too?
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

NTLinks Maker only links for passed files (so if you pass *.bin it will create links for these files only), also it can't schedule link creation for new files.

From TC, press Num+ and type *.bin or put cursor onto any .bin file and press Alt+Num+ to select all files with such extension.

From batch file, use for command to process only files with *.bin mask.
User avatar
byblo
Senior Member
Senior Member
Posts: 270
Joined: 2005-02-20, 21:13 UTC
Contact:

Post by *byblo »

Thank you for the answer :)

I guess I will link the whole folder then...
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

I guess I will link the whole folder then...
That's the easiest way if extra files don't bother you. :)
User avatar
byblo
Senior Member
Senior Member
Posts: 270
Joined: 2005-02-20, 21:13 UTC
Contact:

Post by *byblo »

Hello :)

Got 2 little requests regarding NT Link Maker:

I also use this tool to search specific files between multiple folders, then select them, and create symbolic links into a single folder, which allows me to browse files with a viewer.
For instance, its very useful to view selected pictures files, like they were in an unique folder.

The problem is that i get an error message (or no error reported and the tool stop working when using /q switch) when trying to make 2 symbolic links from files with same name.

For instance, if I try to put these 2 files in a target folder:
1\test.jpg
2\test.jpg

The tool naturally will report an error and stop when trying to make symbolic link at the second file "2\test.jpg", since an existing file with the exact same name already exist in the target folder.

So my first request is the following: a new switch to automatically use a non-existing symbolic filename to prevent that type of error, for instance /c switch, to tell the tool to try to add some incremental number until one filename is available. In this case, the 2\test.jpg will get the test(1).jpg filename since test.jpg already exist from 1\test.jpg


The second request (much less important) is to set file attribute to the linked files. For instance, /a=ar to set the symbolic files attribute to archive+read-only (this could help to prevent accidental source file modification by some bad viewer that like to modify files)

/a=h for hidden, s for system ect...


I feel the tool could benefit directly those additions. (I could use some batch but it will be much slower to run the tool for every file to link, than having those switches directly added to the tool)
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Well, setting additional attributes maybe handy but it must not be allowed for hardlinks (because it will apply to source files).

Autorename sounds like a good new feature too, but it may be slow in case of adding multiple files with same names.
User avatar
byblo
Senior Member
Senior Member
Posts: 270
Joined: 2005-02-20, 21:13 UTC
Contact:

Post by *byblo »

MVV wrote:Well, setting additional attributes maybe handy but it must not be allowed for hardlinks (because it will apply to source files).
Indeed. The switch /c should be ignored for everything that is not a symbolic link maybe.
MVV wrote:Autorename sounds like a good new feature too, but it may be slow in case of adding multiple files with same names.
Still much faster than running the tool once per file :)
User avatar
DrShark
Power Member
Power Member
Posts: 1872
Joined: 2006-11-03, 22:26 UTC
Location: Kyiv, 68/262
Contact:

Re: NTLinks + NTLinksMaker: NTFS links creation and information

Post by *DrShark »

MVV wrote: 2017-02-26, 09:45 UTC
making symlinks of files after following junctions/folder symlinks is a specific kind of "creating links" job
I think it is a bit excess... Ok, I'll consider that too.
Any chance to see this implemented in NTLinksMaker in near future? (please read several posts starting with this one to recall the context.)

There is also a suggestion for NTLinks about hardlinks.
Usually on the NTFS volume with allowed DOS names for files, primary hardlink (original file which doesn't yet have other hardlink copies) has a short 8.3 name, while secondary hard links (other hard link copies) don't have it (well, at least OS doesn't return correct 8.3 name for them, returning long one instead: as far as I understand, for secondary hardlinks the Windows looks for their $File_Name (Attribute type $30 / 0X30) attribute that has "File name namespase" flag with index value set to 0 (means it's link, has a long name record) instead of 2 (means it's a dos 8.3 name record) and returns this value via API on 8.3 name request.) It was mentioned, with examples, in this topic. So it's a more or less good way to detect a primary hardlink and its presence (the exception case is when primary file is removed, so all new hardlinks can be created only from existing secondary hardlinks.)
I suggest to add folowing info to NTLinks:
a) hardlinked copy with of current hardlink shortname exists (True/False);
b) whether current file is a hardlinked copy with short name (True/False);
c) a path to hardlinked copy with short name, if exists;

NTFS has many other attributes and flags to store different file names (aliases), and more hidden timestamp fields, so it's possible there is another (more reliable) way detect a primary hardlink and/or oldest secondary hardlink.
Donate for Ukraine to help stop Russian invasion!
Ukraine's National Bank special bank account:
UA843000010000000047330992708
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Re: NTLinks + NTLinksMaker: NTFS links creation and information

Post by *MVV »

Any chance to see this implemented in NTLinksMaker in near future?
Ok, I'll add optional enumerating of folder links, also optional copying symlink attributes and optional error ignoring.
There is also a suggestion for NTLinks about hardlinks.
I think that it is a too specific case so I don't want to add such fields. I believe that short names may be added to a hardlink during some operations, and first one may be w/o a short name, so it isn't reliable at all to detect a primary link by presence of a short name, and hardlinks are equal in rights by design.

I think you can get b) with some other plugins, just by checking short name of files (TC has a field that shows short name).
User avatar
DrShark
Power Member
Power Member
Posts: 1872
Joined: 2006-11-03, 22:26 UTC
Location: Kyiv, 68/262
Contact:

Re: NTLinks + NTLinksMaker: NTFS links creation and information

Post by *DrShark »

MVV wrote: 2019-02-27, 14:45 UTCI'll add optional enumerating of folder links, also optional copying symlink attributes and optional error ignoring.
Thanks, I'll wait for new version to try it.
MVV wrote: 2019-02-27, 14:45 UTC
DrShark wrote: 2019-02-26, 16:20 UTCThere is also a suggestion for NTLinks about hardlinks.
I think you can get b) with some other plugins, just by checking short name of files (TC has a field that shows short name).
The problem is that both TC and other software use standard API to get 8.3 names, and in that API request for secondary hardlinks Windows lies about short names, returning long names instead.

The tool I used to check for additional NTFS attributes, LSoft Technologies Active@ Disk Editor, allows to see necessarry info (using its "Inspect file record" item on file and/or parent folder), but it is not a tool for batch work.
MVV wrote: 2019-02-27, 14:45 UTCI believe that short names may be added to a hardlink during some operations, and first one may be w/o a short name, ...
I may be wrong, but I don't think it's possible. I can't imagine how to do this...
MVV wrote: 2019-02-27, 14:45 UTC... so it isn't reliable at all to detect a primary link by presence of a short name, and hardlinks are equal in rights by design.
... but even if there are some exception cases, as for me, this method to detect primary/secondary hardlinks is reliable enough for daily use.
MVV wrote: 2019-02-27, 14:45 UTCI think that it is a too specific case so I don't want to add such fields.
Yes, this case is specific to NTFS Hard Links. It's OK even if the fields I request for will be hidden by default, and available for use after adding some settings to NTLinks configuration file.
Donate for Ukraine to help stop Russian invasion!
Ukraine's National Bank special bank account:
UA843000010000000047330992708
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Re: NTLinks + NTLinksMaker: NTFS links creation and information

Post by *MVV »

The problem is that both TC and other software use standard API to get 8.3 names, and in that API request for secondary hardlinks Windows lies about short names, returning long names instead.
Is it a standard behaviour if no 8.3 name exist? Which API is exactly used? When I do FindFirstFile for two file links, I get expected value in cAlternateFileName field for the first link and empty value for the second one. But GetShortPathName function returns same path for the second link, and I think it is OK for that function (though such case is not documented).
Yes, this case is specific to NTFS Hard Links.
Even more, for hard links in a special rare environment under some conditions... I think that it is not a task for a generic plugin.
User avatar
DrShark
Power Member
Power Member
Posts: 1872
Joined: 2006-11-03, 22:26 UTC
Location: Kyiv, 68/262
Contact:

Re: NTLinks + NTLinksMaker: NTFS links creation and information

Post by *DrShark »

MVV wrote: 2019-02-28, 12:01 UTCIs it a standard behaviour if no 8.3 name exist? Which API is exactly used? When I do FindFirstFile for two file links, I get expected value in cAlternateFileName field for the first link and empty value for the second one. But GetShortPathName function returns same path for the second link, and I think it is OK for that function (though such case is not documented).
Well, I'm not a programmer, but mentioned behavior I can see in TC and cmd.exe (and its commands), I guess they use what I called "standard API."
MVV wrote: 2019-02-28, 12:01 UTCEven more, for hard links in a special rare environment under some conditions... I think that it is not a task for a generic plugin.
I wouldn't call hard links on NTFS volume with shorts names enabled "a special rare environment under some conditions." Also, since your plugin is for NTFS links, I wouldn't call it a "generic plugin" in context of my request. Anyway, so far I'm not aware of any known "generic" or "specific" software solution for the task.
Donate for Ukraine to help stop Russian invasion!
Ukraine's National Bank special bank account:
UA843000010000000047330992708
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Re: NTLinks + NTLinksMaker: NTFS links creation and information

Post by *MVV »

Well, I'm not a programmer, but mentioned behavior I can see in TC and cmd.exe (and its commands), I guess they use what I called "standard API."
Well, TC does really show DOS names for every file, even for one without it, and it looks funny when DOS name column contains something like "МОЯ ЖЕСТКАЯ ССЫЛКА НА ДЛИННЫЙ ФАЙЛ.TXT". :D

But cmd.exe does show short names properly, when I execute dir /x, I see no short names for files which don't have them.
I wouldn't call hard links on NTFS volume with shorts names enabled "a special rare environment under some conditions." Also, since your plugin is for NTFS links, I wouldn't call it a "generic plugin" in context of my request. Anyway, so far I'm not aware of any known "generic" or "specific" software solution for the task.
I mean, short names are not something NTFS-specific or related to NTFS links, it is a compatibility feature that hasn't much sense today.
User avatar
DrShark
Power Member
Power Member
Posts: 1872
Joined: 2006-11-03, 22:26 UTC
Location: Kyiv, 68/262
Contact:

Re: NTLinks + NTLinksMaker: NTFS links creation and information

Post by *DrShark »

MVV wrote: 2019-03-01, 05:53 UTCBut cmd.exe does show short names properly, when I execute dir /x, I see no short names for files which don't have them.
You're right. I tried batch file with secondary hardlink as a parameter:

Code: Select all

set sn=%~s1
echo %sn%
pause
and if link has a long name, it returns a long name for a file (like TC).
MVV wrote: 2019-03-01, 05:53 UTCI mean, short names are not something NTFS-specific or related to NTFS links
That's why I requested short name-related fields only for hard links (fields can have "hardlink" in their name so user won't expect this info for dirs, junctions or symlinks. BTW, from one point of view, shortname itself is a hardlink too, however known file managers just don't show long and short file names as separate files.)
MVV wrote: 2019-03-01, 05:53 UTCit is a compatibility feature that hasn't much sense today.
It's sense is a matter of discussion (for which here is not a good place) and depends on user's working environment.
Donate for Ukraine to help stop Russian invasion!
Ukraine's National Bank special bank account:
UA843000010000000047330992708
Post Reply