{"id":9343,"date":"2022-10-06T18:57:04","date_gmt":"2022-10-06T18:57:04","guid":{"rendered":"https:\/\/max-drake.cc\/?p=9343"},"modified":"2022-10-06T19:43:09","modified_gmt":"2022-10-06T19:43:09","slug":"how-to-add-tags-to-files-on-win-10-cannot-do-it-programmatically-via-powershell","status":"publish","type":"post","link":"https:\/\/max-drake.cc\/?p=9343","title":{"rendered":"How to add tags to files on Win 10 -Cannot do it programmatically via PowerShell"},"content":{"rendered":"I&#8217;ve been working on a project that has been going on for years, I&#8217;m picking up aspects of the project and doing some work on them and then leaving them for a while. I&#8217;ve had issues with finding the relevant documents later as I&#8217;m dipping in and out of the folders and moving things around, and then I need to do a regular fossik to find them. Wasting a lot of time. Then I read an article about using File TAGS so that you can TAG your files with a specific &#8220;TAG&#8221; such as project name , or current, so that if you do a search by Tag rather than drawing name or date it should 1\/ be quicker, as less tags to search through, and you can put pertinent information against a specific file.\n\n<!-- \/wp:post-content -->\n\n<!-- wp:paragraph -->\n\nThe article read was on using Free Programs to do it for you, <a href=\"https:\/\/www.thewindowsclub.com\/best-free-file-tagging-software-for-windows\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>Best free File Tagging Software for Windows 11\/10<\/strong><\/a>\n\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n\nThere is a simple method, in File Explorer to add a TAG to a file, you right hand click on the file and go to properties and then select the DETAIL&#8217;s TAB and in that you can see TAGS and you can add your own TAGS to that field, if you want multiple then you just put a semicolon between each separate tag, eg <strong>TO DO; CURRENT; Lastest Manuscript for Tree Book<\/strong>\n\n<!-- \/wp:paragraph -->\n\n<!-- wp:embed {\"url\":\"https:\/\/www.youtube.com\/watch?v=66bzSjD_sF0\",\"type\":\"video\",\"providerNameSlug\":\"youtube\",\"responsive\":true,\"className\":\"wp-embed-aspect-16-9 wp-has-aspect-ratio\"} -->\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\">\n<div class=\"wp-block-embed__wrapper\">https:\/\/www.youtube.com\/watch?v=66bzSjD_sF0<\/div><\/figure>\n<!-- \/wp:embed -->\n\n<!-- wp:paragraph -->\n\nThis article <strong><a href=\"https:\/\/www.addictivetips.com\/windows-tips\/add-tags-to-files-windows-10\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to add tags to files on Windows 10<\/a><\/strong> demonstrates the process.\n\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n\nIt is a bit of a drawn out process, you can select multiple files in a folder and add the same tags to each at the same time, but still a protracted process.\n\n<!-- \/wp:paragraph -->\n\n<!-- wp:heading {\"level\":3} -->\n<h3>More Background<\/h3>\n<!-- \/wp:heading -->\n\n<!-- wp:paragraph -->\n\nI do actually have an AutoHotKey program called <strong><a href=\"https:\/\/github.com\/drakemax\/FileSaveLaunch\" target=\"_blank\" rel=\"noreferrer noopener\">FileSaveLaunch<\/a><\/strong> (available on Github) that does allow you to store a link to a file with a description of that file and what project it relates to. But this is an external program.\n\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n\nI thought it would be interested in storing TAGS in the file itself, so you searched for that specific file.\n\n<!-- \/wp:paragraph -->\n\n<!-- wp:heading {\"level\":3} -->\n<h3>Using Software<\/h3>\n<!-- \/wp:heading -->\n\n<!-- wp:paragraph -->\n\nI looked at the free software programs ( see link above) and of the 5 programs the last, TagSpaces Lite was recommended, and when I went into it a bit further there was a free version and a pro version, the free version did most things but would not tag in the cloud, so if you moved your files to the cloud they would lose their tags unless you used the pro version.\n\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n\nAlso I didn&#8217;t want to have to use a specific program to 1\/ Create the tags and 2\/ Fnd the tags.\n\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n\nThinking about it I thought, how hard is it to write a little program to actually do this, say 1\/ select a file and then 2\/ have a pop-up box for the tags you want to add.\n\n<!-- \/wp:paragraph -->\n\n<!-- wp:heading {\"level\":3} -->\n<h3>Doing it programmatically<\/h3>\n<!-- \/wp:heading -->\n\n<!-- wp:paragraph -->\n\nI wondered about doing it programmatically using maybe DOS, PowerShell or even AutoHotKeys to do so. So I started looking on the interwongle to see if it ca be done.\n\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n\nI came across a lot of interesting things. Most distracting.\n\n<!-- \/wp:paragraph -->\n\n<!-- wp:heading {\"level\":3} -->\n<h3>Firstly AutoHotKey<\/h3>\n<!-- \/wp:heading -->\n\n<!-- wp:paragraph -->\n\nI thought AutoHotKey would be a good method to choose the files and then have a GUI to add tags, and looking on the interwongle I came across this article that I thought was a smart use of file metadata using AutoHotKey. <a href=\"http:\/\/www.disavian.net\/rename-autohotkey-metadata\/\" target=\"_blank\" rel=\"noreferrer noopener\">Renaming music files via AutoHotkey and metadata<\/a>. On looking at it in depth it reads the file metadata to find ARTIST and music TRACK NUMBER and pulls this out of the File Metadata and creates a new filename that includes these two elements, so that its more easy to structure his music by artist. So this is about reading and extracting File metadata, not writing to it.\n\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n\nThere was another <strong><a href=\"https:\/\/learn.microsoft.com\/en-us\/windows\/win32\/fileio\/file-streams?redirectedfrom=MSDN\" target=\"_blank\" rel=\"noreferrer noopener\">article<\/a><\/strong> about File Metadata on AutoHotKey forum that had a suggestion about File Streams. See next topic\n\n<!-- \/wp:paragraph -->\n\n<!-- wp:heading {\"level\":3} -->\n<h3>&#8220;Super Hidden&#8221; Files in Windows<\/h3>\n<!-- \/wp:heading -->\n\n<!-- wp:paragraph -->\n\nThis was an interesting video using File Streams to embed other files inside a file. The issue is f you copy it to another PC or device the inner, &#8220;hidden&#8221; file disappears, so not that useful when copying files to backup storage places as you loose the stuff.\n\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n\nInteresting but not useful in this situation as I move my files around.\n\n<!-- \/wp:paragraph -->\n\n<!-- wp:embed {\"url\":\"https:\/\/www.youtube.com\/watch?v=3BWTo87oCwc\",\"type\":\"video\",\"providerNameSlug\":\"youtube\",\"responsive\":true,\"className\":\"wp-embed-aspect-16-9 wp-has-aspect-ratio\"} -->\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\">\n<div class=\"wp-block-embed__wrapper\">https:\/\/www.youtube.com\/watch?v=3BWTo87oCwc<\/div><\/figure>\n<!-- \/wp:embed -->\n\n<!-- wp:heading {\"level\":3} -->\n<h3>How to Change File and Folder Date &amp; Time Attributes Via the Command Line<\/h3>\n<!-- \/wp:heading -->\n\n<!-- wp:paragraph -->\n\nI came across this video that changes date attributes for files and I thought it was a great start to what I wanted to do\n\n<!-- \/wp:paragraph -->\n\n<!-- wp:embed {\"url\":\"https:\/\/www.youtube.com\/watch?v=p99Sf\\u002d\\u002dP7F8\",\"type\":\"video\",\"providerNameSlug\":\"youtube\",\"responsive\":true,\"className\":\"wp-embed-aspect-16-9 wp-has-aspect-ratio\"} -->\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\">\n<div class=\"wp-block-embed__wrapper\">https:\/\/www.youtube.com\/watch?v=p99Sf&#8211;P7F8<\/div><\/figure>\n<!-- \/wp:embed -->\n\n<!-- wp:paragraph -->\n\nSo I started looking for how to get the actual TAGS item, and found that within a file it has lots of ATTRIBUTES, displayed below using powerShell script\n\n<!-- \/wp:paragraph -->\n\n<!-- wp:image {\"id\":9344,\"sizeSlug\":\"large\",\"linkDestination\":\"none\"} -->\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1012\" height=\"1024\" class=\"wp-image-9344 lazyload\" data-src=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2022\/10\/2022-10-07-17_17_01-Windows-PowerShell-ISE-1012x1024.jpg\" alt=\"\" data-srcset=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2022\/10\/2022-10-07-17_17_01-Windows-PowerShell-ISE-1012x1024.jpg 1012w, https:\/\/max-drake.cc\/wp-content\/uploads\/2022\/10\/2022-10-07-17_17_01-Windows-PowerShell-ISE-296x300.jpg 296w, https:\/\/max-drake.cc\/wp-content\/uploads\/2022\/10\/2022-10-07-17_17_01-Windows-PowerShell-ISE-768x777.jpg 768w, https:\/\/max-drake.cc\/wp-content\/uploads\/2022\/10\/2022-10-07-17_17_01-Windows-PowerShell-ISE-50x51.jpg 50w, https:\/\/max-drake.cc\/wp-content\/uploads\/2022\/10\/2022-10-07-17_17_01-Windows-PowerShell-ISE-49x50.jpg 49w, https:\/\/max-drake.cc\/wp-content\/uploads\/2022\/10\/2022-10-07-17_17_01-Windows-PowerShell-ISE-100x100.jpg 100w, https:\/\/max-drake.cc\/wp-content\/uploads\/2022\/10\/2022-10-07-17_17_01-Windows-PowerShell-ISE-99x100.jpg 99w, https:\/\/max-drake.cc\/wp-content\/uploads\/2022\/10\/2022-10-07-17_17_01-Windows-PowerShell-ISE-632x640.jpg 632w, https:\/\/max-drake.cc\/wp-content\/uploads\/2022\/10\/2022-10-07-17_17_01-Windows-PowerShell-ISE-640x648.jpg 640w, https:\/\/max-drake.cc\/wp-content\/uploads\/2022\/10\/2022-10-07-17_17_01-Windows-PowerShell-ISE-759x768.jpg 759w, https:\/\/max-drake.cc\/wp-content\/uploads\/2022\/10\/2022-10-07-17_17_01-Windows-PowerShell-ISE-1024x1036.jpg 1024w, https:\/\/max-drake.cc\/wp-content\/uploads\/2022\/10\/2022-10-07-17_17_01-Windows-PowerShell-ISE-1067x1080.jpg 1067w, https:\/\/max-drake.cc\/wp-content\/uploads\/2022\/10\/2022-10-07-17_17_01-Windows-PowerShell-ISE.jpg 1424w\" data-sizes=\"(max-width: 1012px) 100vw, 1012px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1012px; --smush-placeholder-aspect-ratio: 1012\/1024;\" \/><\/figure>\n<!-- \/wp:image -->\n\n<!-- wp:paragraph -->\n\nThe code for generating the above list (that goes on for over 300 items) is below. The item we want is item 5 in the above list but is item 18 on another list.\n\n<!-- \/wp:paragraph -->\n\n<!-- wp:code -->\n<pre class=\"wp-block-code\"><code>$folder = (New-Object -ComObject Shell.Application).NameSpace(\"$pwd\")\n# Note: Assumes that no indices higher than 1000 exist.\n0..1000 | % { \n  if ($n = $folder.GetDetailsOf($null, $_)) { \n    [pscustomobject] @{ Index = $_; Name = $n } \n  } \n}<\/code><\/pre>\n<!-- \/wp:code -->\n\n<!-- wp:heading {\"level\":3} -->\n<h3>File MetaData Attributes differ or may not exist for specific file types<\/h3>\n<!-- \/wp:heading -->\n\n<!-- wp:paragraph -->\n\nWhen I looked up a speccific file type, .RVT, for BIM it did not have the TAGS metadata attribute at all, so that sort of limited my use of this method, as I thought that certain metadata attributes were common to all files such as Comments and other similar attributes, but obviously not!\n\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n\nSo I found an article <strong><a href=\"https:\/\/www.addictivetips.com\/windows-tips\/enable-tags-for-unsupported-files-windows-10\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to enable tags for unsupported files on Windows 10<\/a><\/strong> that allowed you to add the attributes to a file type. The program <strong><a href=\"https:\/\/github.com\/Dijji\/FileMeta\/wiki\/Using-the-File-Meta-Association-Manager\" target=\"_blank\" rel=\"noreferrer noopener\">File Meta Association Manager<\/a><\/strong> is available on Github.\n\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n\nI downloaded it and added the associations to that .RVT file type. I then added a value to the TAGS attribute for a file and copied it to my NAS storage and the .RVT file type retained the attribute and its value.\n\n<!-- \/wp:paragraph -->\n\n<!-- wp:heading {\"level\":3} -->\n<h3>PowerShell to write script for adding value to file attribute- NO<\/h3>\n<!-- \/wp:heading -->\n\n<!-- wp:paragraph -->\n\nIn powershell you can read the attribute data from a file but you cannot write attribute values to a file. This is not clear and I wasted a couple of days trying to get this to work and finally came across this article <strong><a href=\"https:\/\/social.technet.microsoft.com\/Forums\/en-US\/8246b1f5-b11b-4d5e-8a07-1bcd5f94852c\/how-to-write-extended-properties?forum=ITCG&amp;prof=required\" target=\"_blank\" rel=\"noreferrer noopener\">How to Write Extended Properties<\/a><\/strong> in which it clearly states that you need the original comObject (Excel, Word etc) to be able to write to the file attributes. So for PowerShell you can read all the metadata attributes, just not write to many at all. So a bit disappointing.\n\n<!-- \/wp:paragraph -->\n\n<!-- wp:heading {\"level\":3} -->\n<h3>TagLib.dll<\/h3>\n<!-- \/wp:heading -->\n\n<!-- wp:paragraph -->\n\nI did come across a <strong><a href=\"https:\/\/blog.kmsigma.com\/2018\/10\/02\/photo-organization-via-powershell-and-tags\/\" target=\"_blank\" rel=\"noreferrer noopener\">taglib.dll<\/a><\/strong> but it only works on media files, so is a bit limited.\n\n<!-- \/wp:paragraph -->\n\n<!-- wp:heading {\"level\":3} -->\n<h3>End Comment<\/h3>\n<!-- \/wp:heading -->\n\n<!-- wp:paragraph -->\n\nI was interested in this project for a couple of reasons: Initially to get the TAGS actually embedded in the actual file, rather than an external link to the file as with <strong><a href=\"https:\/\/github.com\/drakemax\/FileSaveLaunch\" target=\"_blank\" rel=\"noreferrer noopener\">FileSaveLaunch<\/a><\/strong>. I wanted to do it without a 3rd party program, so that if I shared the files with anyone the tags would still be usable.\n\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n\nOn getting involved in the project I was interested in getting to dive into powerSHELL again. I&#8217;ve a couple of simple scripts that I use AutoHotKey to activate and they work great, so adding another script I thought would be good at getting me a little more familiar with PowerShell. As it is , it was a failure.\n\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n\nOn reflection you wonder what is the point of these outside of Media files where they are used extensively.\n\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n\nIn the end I will stick with my FileSaveLaunch program but I may manually tag a few important files using File Manager to add them.\n\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n\nWhat I thought would be something reasonably easy ended up being an interesting journey but with a disappointing end.\n\n<!-- \/wp:paragraph -->","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been working on a project that has been going on for years, I&#8217;m picking up aspects of the project and doing some work on them and then leaving them for a while. I&#8217;ve had issues with finding the relevant documents later as I&#8217;m dipping in and out of the folders and moving things around, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":9344,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[466,204,42],"tags":[],"class_list":["post-9343","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-autohotkey","category-automation","category-productivity"],"featured_image_src":"https:\/\/max-drake.cc\/wp-content\/uploads\/2022\/10\/2022-10-07-17_17_01-Windows-PowerShell-ISE-600x400.jpg","featured_image_src_square":"https:\/\/max-drake.cc\/wp-content\/uploads\/2022\/10\/2022-10-07-17_17_01-Windows-PowerShell-ISE-600x600.jpg","author_info":{"display_name":"Max Drake","author_link":"https:\/\/max-drake.cc\/?author=1"},"_links":{"self":[{"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/posts\/9343","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=9343"}],"version-history":[{"count":2,"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/posts\/9343\/revisions"}],"predecessor-version":[{"id":9350,"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/posts\/9343\/revisions\/9350"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/media\/9344"}],"wp:attachment":[{"href":"https:\/\/max-drake.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9343"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9343"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9343"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}