Page 1 of 1
[Solved] Find & fix wrong case sensitive filepath in tag.dat
Posted: 25 Oct 2016 14:22
by xnmp
(Main question) :
is it possible to find and fix wrong case sensitive filepath in tag.dat such as
e:\list\a.jpg|||0 while the actual filepath is
e:\LIST\a.jpg (actual folder is "
LIST" while in tag.dat is "
list")
(the wrong tag maybe because of this bug
viewtopic.php?f=2&t=16587)
i want to fix the wrong case sensitive filepath only , ( leave invalid filepath (non-existed filepath) as original ,not touch it )
(special case) :
in case there is the way to fix that, maybe we have two line in tags that contains the same path ,like this
e:\LIST\a.jpg|||0 (the wrong case sensitive path that is fixed)
and e:\LIST\a.jpg||1|0 (the original correct filepath that exist in tag.dat)
i want to manually handle these tags (by myself) ,so i really appreciate if someone who can solve this problem leave it as original (two lines like above) instead of merging (or something)
in other way, i just want to fix the lines (in tag.dat) that have wrong case sensitive filepath,and leave the others lines as original
Sorry for my bad english
Any help would be much appreciated
Re: [help] Find and fix wrong case sensitive filepath in tag
Posted: 25 Oct 2016 14:36
by highend
? You want to keep two existing (in the tag.dat file) file paths that refer to the
SAME file?
Code: Select all
e:\LIST\a.jpg|||0
e:\LIST\a.jpg||1|0
What's the use of that?
Re: [help] Find and fix wrong case sensitive filepath in tag
Posted: 25 Oct 2016 14:47
by xnmp
highend wrote:? You want to keep two existing (in the tag.dat file) file paths that refer to the
SAME file?
Code: Select all
e:\LIST\a.jpg|||0
e:\LIST\a.jpg||1|0
What's the use of that?
Hi,Thank you for concerning :d
i want to manually handle it later because of this :
I use many tags type for various purpose ,like this
I use tags to store the location(filepath) from that the file i copied , but because of this bug
viewtopic.php?f=2&t=16587 the tag would not be displayed in xyplorer ,i didn't know that before ,so i did set the tag again when replace file from another location , so i want to leave it separately ,for later finding out what location i copied that file from
(It's the same file ,but it's a file that is replaced from many different locations)
like we install the game mods, we want to know the file in game is from which mods, while there are many mods that have the same filepath
Thanks
Re: [help] Find and fix wrong case sensitive filepath in tag
Posted: 25 Oct 2016 14:50
by highend
If you just want to fix wrong case sensitive paths, write a script
- foreach / while loop over all entries
- gettoken to get the path of each of them
- exists() to test if the path exists
- if yes, compare both case-sensitive
-> if they don't match, replace the path with the existing path
-> else continue
this will leave out non existing paths as you require it...
Re: [help] Find and fix wrong case sensitive filepath in tag
Posted: 25 Oct 2016 14:53
by xnmp
Thank you very much , highend
i will try it

Re: [help] Find and fix wrong case sensitive filepath in tag
Posted: 25 Oct 2016 15:28
by xnmp
highend wrote:If you just want to fix wrong case sensitive paths, write a script
- exists() to test if the path exists
- if yes, compare both case-sensitive
hi again,
how to get the actual (real) filepath case sensitive, (using the filepath we get in tag.dat)
i think about browsing it through xy (using run ,xyplorer.exe %filepath%)
and use "get itempath name" (#101 command) to copy it to clipboard
but i think there is a faster way
Please tell me how to do that
Thanks in advance
Re: [help] Find and fix wrong case sensitive filepath in tag
Posted: 25 Oct 2016 15:29
by highend
Code: Select all
$realPath = property("System.ItemPathDisplay", <your current item in the foreach / while loop>);
Re: [help] Find and fix wrong case sensitive filepath in tag
Posted: 25 Oct 2016 15:30
by xnmp
highend wrote:Code: Select all
$realPath = property("System.ItemPathDisplay", <your current item in the foreach loop>);
Thank you very much for very quick reply, i really appreciate it

Re: [help] Find and fix wrong case sensitive filepath in tag
Posted: 25 Oct 2016 16:08
by xnmp
highend wrote:Code: Select all
$realPath = property("System.ItemPathDisplay", <your current item in the foreach / while loop>);
Hi , i write the script ,it runs but not works, (the new created file has the same content to the old one)
i copy the tag content to text file and run the script ,then i open outputtag.txt (the result file) and i see that the path is not corrected yet
Please help
Code: Select all
$file = "E:\Program Files\xy\BACKUP\tag-v01a-01.txt";
$content = readfile($file,,,65001);
foreach($entry, $content, <crlf>, "e") {
$tagpath = gettoken($entry, 1, "|");
if (exists($tagpath))
{
$realPath = property("System.ItemPathDisplay", $tagpath);
if (compare($tagpath,$realPath,b) != 0)
{
$content = replace($content,$tagpath,$realPath);
}
}
}
writefile("E:\Program Files\xy\BACKUP\outputtag.txt",$content,,,);
Thanks
Re: [help] Find and fix wrong case sensitive filepath in tag
Posted: 25 Oct 2016 16:19
by highend
You're calling replace() without assigning the result back to $content^^
Btw, a while loop is better because the replace can't go wrong (it's executed
on each line only, not on $content)...
Re: [help] Find and fix wrong case sensitive filepath in tag
Posted: 25 Oct 2016 16:30
by xnmp
highend wrote:You're calling replace() without assigning the result back to $content^^
Btw, a while loop is better because the replace can't go wrong (it's executed
on each line only, not on $content)...
Thank you very much, i fixed and it works fine
about the while loop, i don't get it, could you please tell me more detail about it (the main steps how to do it)
Thank you

Re: [help] Find and fix wrong case sensitive filepath in tag
Posted: 25 Oct 2016 16:41
by highend
It's nearly the same as a foreach loop only with a counter variable
Code: Select all
while ($i++ < gettoken($tags, "count", <crlf>)) {
and inside the loop each line can be retrieved via:
Code: Select all
$item = gettoken($tags, $i, <crlf>);
while $tags was defined before the loop with (it gets only the tags from tag.dat):
Code: Select all
$tags = gettoken($content, 2, "Data:<crlf>");
The rest (what happens inside the loop) is nearly identical apart that you won't even
need to replace something but building a new $list by concatenating the $realpath
with it's data part and putting it in a <crlf> separated list again.
A bit slower but far more reliable because a replace can't do any harm when used
on $content. Although this might cause no real problems if replace() is used with
count = 1 -> Only the first found match would be replaced...
Re: [solved] Find and fix wrong case sensitive filepath in t
Posted: 25 Oct 2016 16:55
by xnmp
highend wrote:
A bit slower but far more reliable because a replace can't do any harm when used
on $content. Although this might cause no real problems if replace() is used with
count = 1 -> Only the first found match would be replaced...
I don't understand about the problem if i use "replace all" instead of "count = 1" ,would you like telling more about it
(i think it's fine to replace all incorrect case-sensitive filepath ,so i use replace all)
are you talking about accidently replacing the tag content instead of the filepath content ( if the tags contains filepath), or something ?
Thank you very much

Re: [Solved] Find & fix wrong case sensitive filepath in tag
Posted: 25 Oct 2016 17:56
by highend
Normally the tag.dat shouldn't contain non existing files / folders. But you want it
to contain them on purpose. If you're sure a global replace can't harm them -> Then it's ok
(I guess you aren't tagging files with a file / folder as the tag's content)
Re: [Solved] Find & fix wrong case sensitive filepath in tag
Posted: 25 Oct 2016 18:29
by xnmp
i see, thank you for everything