Add/Set tags, label, comment to duplicate file

Discuss and share scripts and script files...
Post Reply
Norn
Posts: 504
Joined: 24 Oct 2021 16:10

Add/Set tags, label, comment to duplicate file

Post by Norn »

Code: Select all

//Created : 2022-05-29
//Modified: 2022-07-13
//Function: Add/Set tags, label, comment to duplicate file
//Version : v0.5.5

"Add tag(s) to duplicate file"
 $list = report("{fullname}<crlf>",0);                                  //Get list
 $item1 = gettoken($list, 1, "<crlf>");                                 //Get the first item
 $item2 = gettoken($list, 2, "<crlf>");                                 //Get the second item
 $tag1 = tagitems("tags", , $item1, 1);                                 //Get the tags of the first item
 $tag2 = tagitems("tags", , $item2, 1);                                 //Get the tags of the second item
 $backup = "<xydata>" . "\Database backup\" . "tag.dat_backup" . "<date yymmdd-hhmm>" . ".dat";        //Set backup directory
 
 if($tag1 != "") {$item1 = "$item1" . "<crlf>" . "The first item has the tag(s):" . "$tag1";}         //Add hint
 if($tag2 != "") {$item2 = "$item2" . "<crlf>" . "The second item has the tag(s):" . "$tag2";}        //Add hint

 $Confirm = confirm("Note: In the paper folder make sure the list is even and sorted correctly<crlf><crlf>'Yes' set the tag(s) of the first item of each group to the second item<crlf>'No' set the tag(s) of the second item of each group to the first item<crlf><crlf>Secondary sorting is required in the paper folder, here is one group of the list, check it :<crlf>$item1<crlf><crlf>$item2", , , 4);

//If 'Yes' is selected
 if $Confirm == "1" {
//Ask again, cancel to exit script
 if confirm("Are you sure to set the tag(s) of the first item of each group to the second item?<crlf><crlf>All tags, labels and comments will be backed up to:<crlf>$backup") == "0" {end '1==1';}
 tagexport("$backup", "", 0); wait '800';   //Backup, export database
 $Statu = "1";

//Each item of list
 foreach($item, $list, "<crlf>", "e") {
    //Switch $Statu
    switch ($Statu) {
       //If $Statu is equal to 2, then
       case "2":
	      $tagged = "";
		  $tagged = tagitems("tags", , $item, 1);
		  //If $tag is not empty, the target item has the tag(s) and is not equal to $tag, then add (not set) the tag(s) of $tag to the target item
		  if($tag != "" && $tagged != "" && $tagged != $tag) {tag($tag, "$item", 1, 0); msg "Target item has tag(s), changed to add mode, tag(s) are added:$tag";}
		  //If $tag is not empty, the target item does not have the tag(s), then set the tag(s) of $tag to the target item
		  if($tag != "" && $tagged == "") {tagitems("tags", "$tag", "$item");}
		  //Set $tag to empty
		  $tag = "";
          //Set $Statu equal to 1, then break
          $Statu = "1"; break;
//If $Statu equals 1, get the tag(s) of $item, set $Statu equal to 2, then break
       case "1":
          $tag = tagitems("tags", , "$item", 1); $Statu = "2";
		  break;
    }
 }
}





//If 'No' is selected
 if $Confirm == "0" {
//Ask again, cancel to exit script
 if confirm("Are you sure to set the tag(s) of the second item of each group to the first item?<crlf><crlf>All tags, labels and comments will be backed up to:<crlf>$backup") == "0" {end '1==1';}
 tagexport("$backup", "", 0); wait '800';   //Backup, export database
 $Statu = "1";

//Each item of list(reverse direction)
 foreach($item, $list, "<crlf>", "re") {
    //Switch $Statu
    switch ($Statu) {
       //If $Statu is equal to 2, then
       case "2":
	      $tagged = "";
		  $tagged = tagitems("tags", , $item, 1);
		  //If $tag is not empty, the target item has the tag(s) and is not equal to $tag, then add (not set) the tag(s) of $tag to the target item
		  if($tag != "" && $tagged != "" && $tagged != $tag) {tag($tag, "$item", 1, 0); msg "Target item has tag(s), changed to add mode, tag(s) are added:$tag";}
		  //If $tag is not empty, the target item does not have the tag(s), then set the tag(s) of $tag to the target item
		  if($tag != "" && $tagged == "") {tagitems("tags", "$tag", "$item");}
		  //Set $tag to empty
		  $tag = "";
          //Set $Statu equal to 1, then break
          $Statu = "1"; break;
//If $Statu equals 1, get the tag(s) of $item, set $Statu equal to 2, then break
       case "1":
          $tag = tagitems("tags", , "$item", 1); $Statu = "2";
		  break;
    }
 }
}
 msg "Done, check the list!";









"Set (label) to duplicate file"
 $list = report("{fullname}<crlf>",0);                                  //Get list
 $item1 = gettoken($list, 1, "<crlf>");                                 //Get the first item
 $item2 = gettoken($list, 2, "<crlf>");                                 //Get the second item
 $lbl1 = tagitems("lbl", , $item1, 1);                                  //Get the label of the first item
 $lbl2 = tagitems("lbl", , $item2, 1);                                  //Get the label of the second item
 $backup = "<xydata>" . "\Database backup\" . "tag.dat_backup" . "<date yymmdd-hhmm>" . ".dat";        //Set backup directory
 
 if($lbl1 != "") {$item1 = "$item1" . "<crlf>" . "The first item has the label:" . "$lbl1";}          //Add hint
 if($lbl2 != "") {$item2 = "$item2" . "<crlf>" . "The second item has the label:" . "$lbl2";}         //Add hint
 
 $Confirm = confirm("Note: In the paper folder make sure the list is even and sorted correctly<crlf><crlf>'Yes' set the (label) of the first item of each group to the second item<crlf>'No' set the (label) of the second item of each group to the first item<crlf><crlf>Secondary sorting is required in the paper folder, one group of the list, check it :<crlf>$item1<crlf><crlf>$item2", , , 4);

//If 'Yes' is selected
 if $Confirm == "1" {
//Ask again, cancel to exit script
 if confirm("Are you sure to set the label of the first item of each group to the second item?<crlf><crlf>All tags, labels and comments will be backed up to:<crlf>$backup") == "0" {end '1==1';}
 tagexport("$backup", "", 0); wait '800';   //Backup, export database
 $Statu = "1";

//Each item of list
 foreach($item, $list, "<crlf>", "e") {
    //Switch $Statu
    switch ($Statu) {
       //If $Statu is equal to 2, then
       case "2":
          //If $lbl is not empty, set the label of $lbl to $item
	      if($lbl != "") {tagitems("lbl", "$lbl", "$item");}
		  //set $lbl to empty
		  $lbl = "";
          //Set $Statu equal to 1, then break
          $Statu = "1"; break;
//If $Statu is equal to 1, get the label of $item, set $Statu equal to 2, then break
       case "1":
          $lbl = tagitems("lbl", , "$item", 1); $Statu = "2";
		  break;
    }
 }
}





//If 'No' is selected
 if $Confirm == "0" {
//Ask again, cancel to exit script
 if confirm("Are you sure to set the label of the second item of each group to the first item?<crlf><crlf>All tags, labels and comments will be backed up to:<crlf>$backup") == "0" {end '1==1';}
 tagexport("$backup", "", 0); wait '800';   //Backup, export database
 $Statu = "1";

//Each item of list(reverse direction)
 foreach($item, $list, "<crlf>", "re") {
    //Switch $Statu
    switch ($Statu) {
       //If $Statu is equal to 2, then
       case "2":
          //$If $lbl is not empty or equal to 0, then set the label $lbl to $item
	      if($lbl != "" && $lbl != "0") {tagitems("lbl", "$lbl", "$item");}
		  //Set $lbl to empty
		  $lbl = "";
          //Set $Statu equal to 1, then break
          $Statu = "1"; break;
//If $Statu is equal to 1, get the label of $item, set $Statu equal to 2, then break
       case "1":
          $lbl = tagitems("lbl", , "$item", 1); $Statu = "2";
		  break;
    }
 }
}
 msg "Done, check the list!";










"Set (comment) to duplicate file"
 $list = report("{fullname}<crlf>",0);                                  //Get list
 $item1 = gettoken($list, 1, "<crlf>");                                 //Get the first item
 $item2 = gettoken($list, 2, "<crlf>");                                 //Get the second item
 $cmt1 = tagitems("cmt", , $item1, 1);                                  //Get the comment of the first item
 $cmt2 = tagitems("cmt", , $item2, 1);                                  //Get the comment of the second item
 $backup = "<xydata>" . "\Database backup\" . "tag.dat_backup" . "<date yymmdd-hhmm>" . ".dat";        //Set backup directory
 
 if($cmt1 != "") {$item1 = "$item1" . "<crlf>" . "The first item has the comment:" . "$cmt1";}        //Add hint
 if($cmt2 != "") {$item2 = "$item2" . "<crlf>" . "The second item has the comment:" . "$cmt2";}       //Add hint
 
 $Confirm = confirm("Note: In the paper folder make sure the list is even and sorted correctly<crlf><crlf>'Yes' set the (comment) of the first item of each group to the second item<crlf>'No' set the (comment) of the second item of each group to the first item<crlf><crlf>Secondary sorting is required in the paper folder, one group of the list, check it :<crlf>$item1<crlf><crlf>$item2", , , 4);

//If 'Yes' is selected
 if $Confirm == "1" {
//Ask again, cancel to exit script
 if confirm("Are you sure to set the comment of the first item of each group to the second item?<crlf><crlf>All tags, labels and comments will be backed up to:<crlf>$backup") == "0" {end '1==1';}
 tagexport("$backup", "", 0); wait '800';   //Backup, export database
 $Statu = "1";

//Each item of list
 foreach($item, $list, "<crlf>", "e") {
    //Switch $Statu
    switch ($Statu) {
       //If $Statu is equal to 2, then
       case "2":
          //If $cmt is not empty, then set the comment $cmt to $item
	      if($cmt != "") {tagitems("cmt", "$cmt", "$item");}
		  //Set $cmt to empty
		  $cmt = "";
          //Set $Statu equal to 1, then break`
          $Statu = "1"; break;
//If $Statu is equal to 1, get the comment of $item, set $Statu equal to 2, then break
       case "1":
          $cmt = tagitems("cmt", , "$item", 1); $Statu = "2";
		  break;
    }
 }
}





//If 'No' is selected
 if $Confirm == "0" {
//Ask again, cancel to exit script
 if confirm("Are you sure to set the comment of the second item of each group to the first item?<crlf><crlf>All tags, labels and comments will be backed up to:<crlf>$backup") == "0" {end '1==1';}
 tagexport("$backup", "", 0); wait '800';   //Backup, export database
 $Statu = "1";

//Each item of list(reverse direction)
 foreach($item, $list, "<crlf>", "re") {
    //Switch $Statu
    switch ($Statu) {
       //If $Statu is equal to 2, then
       case "2":
          //If $cmt is not empty, set the comment $cmt to $item
	      if($cmt != "") {tagitems("cmt", "$cmt", "$item");}
		  //Set $cmt to empty
		  $cmt = "";
          //Set $Statu equal to 1, then break
          $Statu = "1"; break;
//If $Statu is equal to 1, get the comment of $item, set $Statu equal to 2, then break
       case "1":
          $cmt = tagitems("cmt", , "$item", 1); $Statu = "2";
		  break;
    }
 }
}
 msg "Done, check the list!";





-





"Secondary sort by path(Ascending)"
 sortby "path", "a", 1;









"Secondary sort by path(Descending)"
 sortby "path", "d", 1;
You do not have the required permissions to view the files attached to this post.
Windows 11 24H2 @100% 2560x1440

Norn
Posts: 504
Joined: 24 Oct 2021 16:10

Re: Add/Set tags, label, comment to duplicate file

Post by Norn »

Add or Set Tags, label, comment to duplicate file (Merge all tags) (v0.5.9).xys
Alternate Data Stream version:
Add or Set Tags, label, comment to duplicate file (and add to Alternate Data Stream, NTFS only) (Merge all tags)(v0.6).xys
You do not have the required permissions to view the files attached to this post.
Windows 11 24H2 @100% 2560x1440

Post Reply