Tag Backup - Rev. 1 / 2012/09/15

Discuss and share scripts and script files...
Horst
Posts: 1085
Joined: 24 Jan 2021 12:27
Location: Germany

Re: Tag Backup - Rev. 1 / 2012/09/15

Post by Horst »

As NTFS ADS is still alive and the actual Everything search engine can index and search for streams
I use it successfully with Total Commander and Everything.
Also I can successfully use Highends Everything script to search for my NTFS ADS tagged files.

To make an interface to XY tags I tried this old Tag Backup script.
Its no longer working in the actual XY version.
Is there any update or newer version of it available ?
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
Portable XYplorer (actual version, including betas)
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Tag Backup - Rev. 1 / 2012/09/15

Post by highend »

I've a modified version in a more modern format (with functions)

BUT...

It requires a specific workflow (afaik as the original one as well):
You can't just read existing ads and import them because the script reads a specific stream name.
Any other approach (via cmd) would require a single dir /r via a runret() for each file / folder and a lot of parsing afterwards.

It's better using PowerShell but it has a big drawback as well: Older versions (e.g. 5.x) don't support reading streams for folders...

AlternateStreamView from NirSoft would probably be the best bet but it suffers from using GUI settings when invoked from the command line.
So if you have e.g. the "Full Stream Name" column disabled, a call to it could show no results at all...
One of my scripts helped you out? Please donate via Paypal

Horst
Posts: 1085
Joined: 24 Jan 2021 12:27
Location: Germany

Re: Tag Backup - Rev. 1 / 2012/09/15

Post by Horst »

Thanks for the reply.
I'll stick with my ads Tags from TC.
I can search for them in XY with your Everything script, which is fast as the streams content is indexed.
Settings streams in TC is easy, max 10 different names, with any content.
Deleting streams works with streams.exe from Sysinternals.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
Portable XYplorer (actual version, including betas)
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69

Marco
Posts: 2347
Joined: 27 Jun 2011 15:20

Re: Tag Backup - Rev. 1 / 2012/09/15

Post by Marco »

Horst wrote: 28 Jul 2021 11:49 Is there any update or newer version of it available ?
Hi Horst,
I'm no longer mantaining this script unfortunately - even if I struck that bit in the intro, it was a proof-of-concept I never actually used myself.
Highend's reply is always on point :wink:
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Tag Backup - Rev. 1 / 2012/09/15

Post by highend »

Ok, I've written my own streams utility

It works fine on a few testfiles and folders but I don't use ADS personally, so is there anyone who wants to try it out?

It's a command line application so it's output can easily read by XYplorer to work in conjunction with a runret() script command.

It supports alternate data streams even in overlong paths / files^^
It also allows to delete streams via the flag --delete=1 (default = 0)

To make output parsable with minimal effort it support a few command line flags:

Code: Select all

--sep-name="|" (default = ":")
--sep-type="|" (default = ":")
--sep-size="|" (default = <TAB>)
--omit-type=1  (default = 0)
--omit-size=1  (default = 0)
So the normal output without flags would look like this

Code: Select all

streams_x64.exe "R:\ads"

R:\ads\1 1.txt:filestream1:$DATA        14
R:\ads\3 3.txt:filestream1:$DATA        3
R:\ads\3 3.txt:filestream2:$DATA        4
R:\ads\222:folderstream1:$DATA  5
R:\ads\222\b.txt:filestream1:$DATA      6
This is practically like all other existing tools (Sysinternals streams, Nirsofts AlternateStreamView, etc.)

The parsable way:

Code: Select all

streams_x64.exe "R:\ads" --sep-name="|" --omit-type=1 --omit-size=1

R:\ads\1 1.txt|filestream1
R:\ads\3 3.txt|filestream1
R:\ads\3 3.txt|filestream2
R:\ads\222|folderstream1
R:\ads\222\b.txt|filestream1
One of my scripts helped you out? Please donate via Paypal

Horst
Posts: 1085
Joined: 24 Jan 2021 12:27
Location: Germany

Re: Tag Backup - Rev. 1 / 2012/09/15

Post by Horst »

@highend
I can already search for my ADS streams with Everything script in XY.
I found ADS streams (tags) better suited to my environment compared to XY tags
as I'm using several file managers and Windows Explorer.
So the only missing function in XY is a way to set an ADS stream (tag) on one or several files.
Its not an urgent need as I can easy do it in TC.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
Portable XYplorer (actual version, including betas)
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Tag Backup - Rev. 1 / 2012/09/15

Post by highend »

So the only missing function in XY is a way to set an ADS stream (tag) on one or several files
There is no missing function...

Code: Select all

    $path   = "R:\1.txt";
    $stream = "stream_name";
    $tag    = "some tag";
    writefile("$path:$stream", $tag, , "utf8");
and do that in a loop...
One of my scripts helped you out? Please donate via Paypal

Horst
Posts: 1085
Joined: 24 Jan 2021 12:27
Location: Germany

Re: Tag Backup - Rev. 1 / 2012/09/15

Post by Horst »

Ok, did it like this.
The simple writefile has one big disadvantage, it changes the modified date of the files.
For setting stream tags I don't want to change the file dates and it preserves them in TC.
Is there any simple writefile replacement to preserve the dates ?

Code: Select all

// Set any value to the Tag stream for selected files.

// Check if there's at least one file selected

   $selected    = <get SelectedItemsPathNamesSlashed>;
   $cntSelected = gettoken($selected, "count", <crlf>);
   end ($cntSelected == 0), "No file(s) selected, aborted!";

   $cntFiles = gettoken(formatlist($selected, "f", <crlf>, "!*\"), "count", <crlf>);
   end ($cntSelected != $cntFiles), "Folder(s) can't be selected, aborted!";

   $stream = "Tag";
   $notes = "";
   perm $LastTag;
   $tag = trim(input("Set Tag", $notes, $LastTag, "e"));
   end ($tag == ""), "No tag entered, aborted!";
   $LastTag = $tag;


   foreach($item, $selected, <crlf>, "e") {
        if (exists($item) == 2) { continue; }

    writefile("$item:$stream", $tag, , "utf8");
    };


Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
Portable XYplorer (actual version, including betas)
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Tag Backup - Rev. 1 / 2012/09/15

Post by highend »

No, there isn't. Why don't you just store the date and timestamp the file after writing the stream?
One of my scripts helped you out? Please donate via Paypal

Horst
Posts: 1085
Joined: 24 Jan 2021 12:27
Location: Germany

Re: Tag Backup - Rev. 1 / 2012/09/15

Post by Horst »

highend wrote: 02 Aug 2021 19:05 No, there isn't. Why don't you just store the date and timestamp the file after writing the stream?
Ok, so I will add this to the script.
I have to search the help for some examples how to do this :)
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
Portable XYplorer (actual version, including betas)
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69

Horst
Posts: 1085
Joined: 24 Jan 2021 12:27
Location: Germany

Re: Tag Backup - Rev. 1 / 2012/09/15

Post by Horst »

Its done :D
The script works perfect for me.
It preserves creation and modifictaion times.
Thanks for suggestions and help.

Code: Select all

// Set any value to the Tag stream for selected files.
// The files creation and modification dates are preserved.

// Check if there's at least one file selected
   $selected    = <get SelectedItemsPathNamesSlashed>;
   $cntSelected = gettoken($selected, "count", <crlf>);
   end ($cntSelected == 0), "No file(s) selected, aborted!";

// Folders are not supported
   $cntFiles = gettoken(formatlist($selected, "f", <crlf>, "!*\"), "count", <crlf>);
   end ($cntSelected != $cntFiles), "Folder(s) can't be selected, aborted!";

// Get the new value for Tag
   $stream = "Tag";
   $notes = "";
   perm $LastTag;
   $tag = trim(input("Set Tag", $notes, $LastTag, "e"));
   end ($tag == ""), "No tag entered, aborted!";
   $LastTag = $tag;


   foreach($item, $selected, <crlf>, "e") {
    if (exists($item) == 2) { continue; }

//  Save time stamps, write stream, restore timestamps
    $created  = property("#date.c", $item);
    $modified = property("#date.m", $item);
    writefile("$item:$stream", $tag, , "utf8");
    timestamp "c", $created, $item;
    timestamp "m", $modified, $item;

    };

Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
Portable XYplorer (actual version, including betas)
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Tag Backup - Rev. 1 / 2012/09/15

Post by highend »

writefile() for an existing file doesn't change its created time...
One of my scripts helped you out? Please donate via Paypal

Horst
Posts: 1085
Joined: 24 Jan 2021 12:27
Location: Germany

Re: Tag Backup - Rev. 1 / 2012/09/15

Post by Horst »

highend wrote: 03 Aug 2021 16:14 writefile() for an existing file doesn't change its created time...
Thanks, I removed save/restore creation date now.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
Portable XYplorer (actual version, including betas)
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69

Elessar
Posts: 19
Joined: 22 Sep 2021 17:09

Re: Tag Backup - Rev. 1 / 2012/09/15

Post by Elessar »

Hello Marco,

I am new to XYplorer, and currently, I am trying to see if this is a good solution for me to replace Windows explorer. I noticed the tag capabilities of XYplorer and think it is good, but I was wondering how this can be combined with the tags in, for example, MS Office files. Because the downside of tags in XYplorer is that when files are moved outside XYplorer, the tags get messed up (if I understood correctly). One way to safeguard this would be to sync tags in office files with tags in XYplorer. Of course, other filetypes have other types of tags or no tags at all.

So does your script work in syncing the XYplorer stages with the meta-information tags in MS Office files? Perhaps it is possible to match the tag changes in XYplorer with the tags in Office files? Does your script do that?

Thank you in advance for your consideration!

Kind regards,
Rob

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Tag Backup - Rev. 1 / 2012/09/15

Post by highend »

So does your script work in syncing the XYplorer stages with the meta-information tags in MS Office files?
No, it's about using alternative data streams and office files metadata is not stored inside them. Sure, there are tools to read them (e.g. exiftool can do this) but updating them via a command line tool is a whole different story...
One of my scripts helped you out? Please donate via Paypal

Post Reply