[Solved] Remind user once the bound file in the descript.ion disappears but the comment still exist

English support forum

Moderators: white, Hacker, petermad, Stefan2

hahaha
Junior Member
Junior Member
Posts: 8
Joined: 2016-01-06, 23:43 UTC

[Solved] Remind user once the bound file in the descript.ion disappears but the comment still exist

Post by *hahaha »

Although most of the time I remember renaming and deleting files in TC, in which situation TC can handle the file<->comment bonding correctly. However, sometimes I still forget, and accidentally move the file using Ctrl-C Ctrl-V or changing the filename using other tools (not explorer, just other software).

i really hope being reminded once this happens (or other ways which can prevent this kind of mistakes from the beginning). Probably TC don't have this feature by self and i'm just asking if there's any avenue (including external ones)

a brief thought like finding(infinite loop) all descript.ion in disk using everything and parse them in turn and determine if the corresponding file exists. but coding is hard to me, so have to ask is there any ready-made tool. thanks
Last edited by hahaha on 2018-12-16, 13:37 UTC, edited 1 time in total.
User avatar
tuska
Power Member
Power Member
Posts: 3760
Joined: 2007-05-21, 12:17 UTC

Re: Remind user once the bound file in the descript.ion disappears but the comment still exist

Post by *tuska »

Configuration - Options... - Operation - File comments: ☑ Copy comments with files (press button "Help")
causes file comments to be taken into account when copying, deleting and renaming files in Total Commander.

Attention:
(1) Ctrl-C Ctrl-V or other software is not useful, because then the file comments created with/in TC are lost despite this setting in TC!
     With F5 Copy in TC the file comments are retained. A file deletion causes file comment deletion at the same time.
(2) Only if you want TC file comments to be taken into account during synchronization (e.g. for asymmetric synchronization),
     then you have to uncheck this setting first(!)

Option:
You can color files/folders with TC file comments (Ctrl + Z)
viewtopic.php?p=337415#337415
viewtopic.php?p=336294#336294
User avatar
Hacker
Moderator
Moderator
Posts: 13065
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Re: Remind user once the bound file in the descript.ion disappears but the comment still exist

Post by *Hacker »

hahaha,
Here is a short AHK script that scans descript.ion files' contents for missing files and writes them to MissingFiles.txt:

Code: Select all

StartDir = C:\Test
Recurse = True
ResultFile = MissingFiles.txt

SetWorkingDir, %StartDir%
Loop, Files, descript.ion, % Recurse = "True" ? "R" : ""
{
	FileRead, DescriptIon, %A_LoopFileName%
	Loop, Parse, DescriptIon, `n, `r
	{
		FileName := SubStr(A_LoopField, 1, 1) != """" ? SubStr(A_LoopField, 1, InStr(A_LoopField, " ", , 2) - 1) : SubStr(A_LoopField, 2, InStr(A_LoopField, """ ", , 2) - 2)
		If (FileName != "")
			If (A_LoopFileDir = "")
				MissingFiles .= FileExist(FileName) = "" ? FileName . "`n" : ""
			Else
				MissingFiles .= FileExist(A_LoopFileDir . "\" . FileName) = "" ? A_LoopFileDir . "\" . FileName . "`n" : ""
	}
}
MissingFiles := SubStr(MissingFiles, 1, -1)
FileAppend, %MissingFiles%, %ResultFile%

And here is a functionally equivalent but much easier to understand version:

Code: Select all

StartDir = C:\Test
Recurse = True
ResultFile = MissingFiles.txt

SetWorkingDir, %StartDir%
Loop, Files, descript.ion, % Recurse = "True" ? "R" : ""
{
	FileRead, DescriptIon, %A_LoopFileName%
	Loop, Parse, DescriptIon, `n, `r
		MissingFiles .= (SubStr(A_LoopField, 1, 1) != """" ? SubStr(A_LoopField, 1, InStr(A_LoopField, " ", , 2) - 1) : SubStr(A_LoopField, 2, InStr(A_LoopField, """ ", , 2) - 2)) != "" ? A_LoopFileDir = "" ? FileExist((SubStr(A_LoopField, 1, 1) != """" ? SubStr(A_LoopField, 1, InStr(A_LoopField, " ", , 2) - 1) : SubStr(A_LoopField, 2, InStr(A_LoopField, """ ", , 2) - 2))) = "" ? (SubStr(A_LoopField, 1, 1) != """" ? SubStr(A_LoopField, 1, InStr(A_LoopField, " ", , 2) - 1) : SubStr(A_LoopField, 2, InStr(A_LoopField, """ ", , 2) - 2)) . "`n" : "" : FileExist(A_LoopFileDir . "\" . (SubStr(A_LoopField, 1, 1) != """" ? SubStr(A_LoopField, 1, InStr(A_LoopField, " ", , 2) - 1) : SubStr(A_LoopField, 2, InStr(A_LoopField, """ ", , 2) - 2))) = "" ? A_LoopFileDir . "\" . (SubStr(A_LoopField, 1, 1) != """" ? SubStr(A_LoopField, 1, InStr(A_LoopField, " ", , 2) - 1) : SubStr(A_LoopField, 2, InStr(A_LoopField, """ ", , 2) - 2)) . "`n" : "" : ""
}
MissingFiles := SubStr(MissingFiles, 1, -1)
FileAppend, %MissingFiles%, %ResultFile%
HTH
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
tuska
Power Member
Power Member
Posts: 3760
Joined: 2007-05-21, 12:17 UTC

Re: Remind user once the bound file in the descript.ion disappears but the comment still exist

Post by *tuska »

2Hacker
The scripts don't work for me yet.

Code: Select all

StartDir = D:\Daten
EDIT: There were only folders…

MissingFiles.txt
  • 726(!) x file "_2018-09-22_Total Commander-ADMINISTRATOR.png" in a lot of subdirs
  • in a total of 2,176 lines
  • "EDV\EXCEL" is displayed even though D:\Daten\EDV\EXCEL does not exist
  • "EDV\Acrobat\EXCEL" is displayed even though folder EXCEL does not exist - I can't imagine there's ever been a combination like this.
  • "EDV\Autostart\EXCEL" is displayed even though folder EXCEL does not exist
  • and so on...
Could you please check. Thank you!

EDIT:
The script obviously doesn't consider subfolders at the moment but only the set path.
The file name for which a comment was created is written to the MissingFiles.txt file,
but the file has been moved or deleted and the file comment still exists in the hidden descript.ion file.
In my opinion, the script only works for file comments and not for folder comments.
Last edited by tuska on 2018-12-16, 13:39 UTC, edited 1 time in total.
User avatar
tuska
Power Member
Power Member
Posts: 3760
Joined: 2007-05-21, 12:17 UTC

Re: Remind user once the bound file in the descript.ion disappears but the comment still exist

Post by *tuska »

2Hacker
Your script works for me for files in a single predefined folder path.

For me it would be very interesting if you could create an evaluation including subdirectories or for an entire drive.
In this case, the file MissingFiles.txt would need to contain the path in addition to the filenames.

Could you add this function to your script, please?

Regards
Karl
hahaha
Junior Member
Junior Member
Posts: 8
Joined: 2016-01-06, 23:43 UTC

Re: Remind user once the bound file in the descript.ion disappears but the comment still exist

Post by *hahaha »

Hacker wrote: 2018-12-16, 01:38 UTC
wow, the script works great! thank you, did u just code it or already use it for some time? i know coding takes time a lot, really appreciate your help! :D
User avatar
Hacker
Moderator
Moderator
Posts: 13065
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Re: [Solved] Remind user once the bound file in the descript.ion disappears but the comment still exist

Post by *Hacker »

tuska,
it would be very interesting if you could create an evaluation including subdirectories or for an entire drive.
In this case, the file MissingFiles.txt would need to contain the path in addition to the filenames.
Umm, it's already there? Just set:

Code: Select all

StartDir = C:\
Recurse = True
[...] is displayed even though D:\Daten\EDV\EXCEL does not exist
I am not sure I understand your other issue - of course the files that don't exist are displayed, that is the point of the script, to show files which are in descript.ion but do not exist.

hahaha,
You're welcome. I just coded it, it's not a complex script and a small challenge is always welcome. ;)

Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
tuska
Power Member
Power Member
Posts: 3760
Joined: 2007-05-21, 12:17 UTC

Re: [Solved] Remind user once the bound file in the descript.ion disappears but the comment still exist

Post by *tuska »

2Hacker
This is the changed script ("Recurse = True" already existed!):
StartDir = D:\
Recurse = True
ResultFile = MissingFiles.txt

SetWorkingDir, %StartDir%
Loop, Files, descript.ion, % Recurse = "True" ? "R" : ""
{
FileRead, DescriptIon, %A_LoopFileName%
Loop, Parse, DescriptIon, `n, `r
{
FileName := SubStr(A_LoopField, 1, 1) != """" ? SubStr(A_LoopField, 1, InStr(A_LoopField, " ", , 2) - 1) : SubStr(A_LoopField, 2, InStr(A_LoopField, """ ", , 2) - 2)
If (FileName != "")
If (A_LoopFileDir = "")
MissingFiles .= FileExist(FileName) = "" ? FileName . "`n" : ""
Else
MissingFiles .= FileExist(A_LoopFileDir . "\" . FileName) = "" ? A_LoopFileDir . "\" . FileName . "`n" : ""
}
}
MissingFiles := SubStr(MissingFiles, 1, -1)
FileAppend, %MissingFiles%, %ResultFile%
With "spoiler" you don't see the indentations exactly like in the code...

Code: Select all

StartDir = D:\
Recurse = True
ResultFile = MissingFiles.txt

SetWorkingDir, %StartDir%
Loop, Files, descript.ion, % Recurse = "True" ? "R" : ""
{
	FileRead, DescriptIon, %A_LoopFileName%
	Loop, Parse, DescriptIon, `n, `r
	{
		FileName := SubStr(A_LoopField, 1, 1) != """" ? SubStr(A_LoopField, 1, InStr(A_LoopField, " ", , 2) - 1) : SubStr(A_LoopField, 2, InStr(A_LoopField, """ ", , 2) - 2)
		If (FileName != "")
			If (A_LoopFileDir = "")
				MissingFiles .= FileExist(FileName) = "" ? FileName . "`n" : ""
			Else
				MissingFiles .= FileExist(A_LoopFileDir . "\" . FileName) = "" ? A_LoopFileDir . "\" . FileName . "`n" : ""
	}
}
MissingFiles := SubStr(MissingFiles, 1, -1)
FileAppend, %MissingFiles%, %ResultFile%
Example:
- If I look directly in "Everything" for file "starttc.exe", then this file is present here: D:\starttc.exe (1x)! (...for a USB stick installation)
- If I filter in D:\MissingFiles.txt for file "starttc.exe", then this file appears in 867 lines in the most different folders (of 5202 lines),
  i.e. under folder Bilder\*.*, Daten\*.*, TC\*.*, TomTomGo..\*.*, Videos\*.* and zTEST\2011\starttc.exe --> File with comment was never there!
- Furthermore the folder zTEST\2011\TC is listed --> this folder does not exist and has never existed there.

For me this script is currently not usable for subfolders.
Mmhh?
Can you please look at this again?
I would very much like subdirectories to work for me.
I am not sure I understand your other issue - of course the files that don't exist are displayed, that is the point of the script, to show files which are in descript.ion but do not exist.
I think I've understood the way your script works, but I don't have any programming knowledge.
The file name for which a comment was created is written to the MissingFiles.txt file,
but the file has been moved or deleted and the file comment still exists in the hidden descript.ion file.
Btw,
d: wfn:descript.ion in "Everything" brings up 868 entries.
User avatar
Hacker
Moderator
Moderator
Posts: 13065
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Re: [Solved] Remind user once the bound file in the descript.ion disappears but the comment still exist

Post by *Hacker »

Wow, the Black board style works really nice! :shock:

tuska,
Can you share a ZIP of an example directory structure including descript.ion files? I guess it will be much easier to reproduce that way.
EDIT: To make sure, are you using AHK 1.1.21 or newer?

TIA
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
tuska
Power Member
Power Member
Posts: 3760
Joined: 2007-05-21, 12:17 UTC

Re: [Solved] Remind user once the bound file in the descript.ion disappears but the comment still exist

Post by *tuska »

2Hacker
I use "AutoHotkey - Current version: v1.1.30.01 - November 11, 2018".

Please find here the folder structure and files (additionally illustrated) - please see also file zTEST.LST:
https://1drv.ms/f/s!Ah1sWOWAFm-dhh49tk48T1pSHXOl

MissingFiles.txt
Expected result

Code: Select all

D:\zTEST\2010\Folder A\aa.txt
D:\zTEST\2010\Folder E\e.txt
D:\zTEST\2011\FolderZ
D:\zTEST\2011\Folder C\cc.txt
Outcome

Code: Select all

2010\Folder A\zTEST_root.txt
2010\Folder A\2011
2010\Folder E\zTEST_root.txt
2010\Folder E\2011
2011\zTEST_root.txt
2011\2011
2011\Folder C\zTEST_root.txt
2011\Folder C\2011
2012\zTEST_root.txt
2012\2011
2012\Folder B\zTEST_root.txt
2012\Folder B\2011
2012\Folder D\zTEST_root.txt
2012\Folder D\2011
2012\Folder D\Folder X\Folder Y\zTEST_root.txt
2012\Folder D\Folder X\Folder Y\2011
I would like to see the entire path specified in the file "MissingFiles.txt".
Thank you!
User avatar
Hacker
Moderator
Moderator
Posts: 13065
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Re: [Solved] Remind user once the bound file in the descript.ion disappears but the comment still exist

Post by *Hacker »

tuska,
Could you please provide a ZIP file of a directory structure, including some descript.ion files, some existing files and some missing files, where you see problems?

TIA
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
tuska
Power Member
Power Member
Posts: 3760
Joined: 2007-05-21, 12:17 UTC

Re: [Solved] Remind user once the bound file in the descript.ion disappears but the comment still exist

Post by *tuska »

2Hacker
I used the packer plugin DiskDirExtended (*.wcx) with defined file extension: LST and created the directory structure (pls see download link above).
You can open the file zTEST.LST by pressing Ctrl+PgDn and extract the content to any folder (only the path of the script has to be changed then).
The file descript.ion then no longer has the file attribute "Hidden", but that's certainly not a drawback in this case.
Hacker wrote:where you see problems?
The result I have announced above.
The MissingFiles.txt should contain 4 entries.
However, there were 16 entries that did not match.

3 files and 1 folder which had file comments before were moved - ☐ Copy comments with files.
Please see: "D-zTEST_Dateikommentare NACH Verschiebung von Dateien und 1 Ordner.png".
-----------
Additionally I have now uploaded file zTEST.7z.
The file attribute "Hidden" was retained in the descript.ion file.
User avatar
Hacker
Moderator
Moderator
Posts: 13065
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Re: [Solved] Remind user once the bound file in the descript.ion disappears but the comment still exist

Post by *Hacker »

tuska,
Thank you for the .7z file. Indeed, I was reading the descript.ion from the start dir over and over, for all dirs. This version should work better:

Code: Select all

StartDir = C:\Test
Recurse = True
ResultFile = MissingFiles.txt
UseAbsolutePaths = True

SetWorkingDir, %StartDir%
Loop, Files, descript.ion, % Recurse = "True" ? "R" : ""
{
	FileRead, DescriptIon, %A_LoopFilePath%
	Loop, Parse, DescriptIon, `n, `r
	{
		FileName := SubStr(A_LoopField, 1, 1) != """" ? SubStr(A_LoopField, 1, InStr(A_LoopField, " ", , 2) - 1) : SubStr(A_LoopField, 2, InStr(A_LoopField, """ ", , 2) - 2)
		If (FileName != "")
			If (A_LoopFileDir = "")
				MissingFiles .= FileExist(FileName) = "" ? UseAbsolutePaths = "True" ? SubStr(A_LoopFileLongPath, 1, InStr(A_LoopFileLongPath, "\", , 0)) . FileName . "`n" : FileName . "`n" : ""
			Else
				MissingFiles .= FileExist(A_LoopFileDir . "\" . FileName) = "" ? UseAbsolutePaths = "True" ? SubStr(A_LoopFileLongPath, 1, InStr(A_LoopFileLongPath, "\", , 0)) . FileName . "`n" : A_LoopFileDir . "\" . FileName . "`n" : ""
	}
}

If (MissingFiles != "")
{
	MissingFiles := SubStr(MissingFiles, 1, -1)
	FileAppend, %MissingFiles%, %ResultFile%
}
I also added an option to use absolute paths for the missing files list.
As for the results, in the .7z you provided there were no missing files, i.e. all the files mentioned in desccript.ion did really exist (there were no "orphaned" comments).

HTH
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
tuska
Power Member
Power Member
Posts: 3760
Joined: 2007-05-21, 12:17 UTC

Re: [Solved] Remind user once the bound file in the descript.ion disappears but the comment still exist

Post by *tuska »

2Hacker
This script works fine for one directory as well as for subdirectories!
The test result this time was as expected (just like above: "Expected result").
Hacker wrote:As for the results, in the .7z you provided there were no missing files, i.e. all the files mentioned in desccript.ion did really exist
(there were no "orphaned" comments).
Yes, unfortunately I gave you the complete folder structure with all files and folders instead of those with already moved files/folder. Sorry!
Hacker wrote:I also added an option to use absolute paths for the missing files list.
I'm very happy about that!

I have now run the script for drive D:, with the result of 468 entries in MissingFiles.txt regarding inconsistent descript.ion files(!)

If I want to investigate the causes here, then the following results:
- In the descript.ion files there are thus orphaned data, with which in the not deleted files
   (i.e. moved files) now the file comments are missing.

- I have been a TC user since 2003 and probably didn't know how to handle descript.ion files for a long time.
- In the meantime, however, I am aware of the following:
   ☐ Copy comments with files -> for [asymmetric] synchronizations (daily multiple backup including hidden descript.ion files!)
   ☑ Copy comments with files -> for files/folders with file comments during copying, renaming or deleting
Let's see what that looks like in a year when I do another query.

Thank you very much for your efforts and the perfect script!

Regards
Karl

------------
Memo
When reviewing and replacing characters with german umlauts (äöüÄÖÜ) and special characters (ß, §), the letter "ü" could not be replaced,
because it was removed from the filename.

Furthermore, a "special character" occurred with a file name, although this was not present in the file name:
D:\Daten\Programme\Adobe\Acrobat\Adobe-Acrobat-11-Pro\Preise\Preise_Adobe AcrobatÿDC.url <-> Preise_Adobe Acrobat DC.url
------------

Windows 10 Pro (x64) Version 1809 (OS Build 17763.194)
TC 9.21a x64/x86 | Everything - Version 1.4.1.923 (x64)
User avatar
Hacker
Moderator
Moderator
Posts: 13065
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Re: [Solved] Remind user once the bound file in the descript.ion disappears but the comment still exist

Post by *Hacker »

tuska,
You're welcome, glad it helped. ;)

Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
Post Reply