How to add tags to files on Win 10 -Cannot do it programmatically via PowerShell

I’ve been working on a project that has been going on for years, I’m picking up aspects of the project and doing some work on them and then leaving them for a while. I’ve had issues with finding the relevant documents later as I’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 “TAG” 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. The article read was on using Free Programs to do it for you, Best free File Tagging Software for Windows 11/10 There 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’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 TO DO; CURRENT; Lastest Manuscript for Tree Book
This article How to add tags to files on Windows 10 demonstrates the process. It 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.

More Background

I do actually have an AutoHotKey program called FileSaveLaunch (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. I thought it would be interested in storing TAGS in the file itself, so you searched for that specific file.

Using Software

I 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. Also I didn’t want to have to use a specific program to 1/ Create the tags and 2/ Fnd the tags. Thinking 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.

Doing it programmatically

I 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. I came across a lot of interesting things. Most distracting.

Firstly AutoHotKey

I 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. Renaming music files via AutoHotkey and metadata. 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. There was another article about File Metadata on AutoHotKey forum that had a suggestion about File Streams. See next topic

“Super Hidden” Files in Windows

This 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, “hidden” file disappears, so not that useful when copying files to backup storage places as you loose the stuff. Interesting but not useful in this situation as I move my files around.

How to Change File and Folder Date & Time Attributes Via the Command Line

I came across this video that changes date attributes for files and I thought it was a great start to what I wanted to do–P7F8
So 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
The 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.
$folder = (New-Object -ComObject Shell.Application).NameSpace("$pwd")
# Note: Assumes that no indices higher than 1000 exist.
0..1000 | % { 
  if ($n = $folder.GetDetailsOf($null, $_)) { 
    [pscustomobject] @{ Index = $_; Name = $n } 

File MetaData Attributes differ or may not exist for specific file types

When 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! So I found an article How to enable tags for unsupported files on Windows 10 that allowed you to add the attributes to a file type. The program File Meta Association Manager is available on Github. I 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.

PowerShell to write script for adding value to file attribute- NO

In 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 How to Write Extended Properties 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.


I did come across a taglib.dll but it only works on media files, so is a bit limited.

End Comment

I 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 FileSaveLaunch. 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. On getting involved in the project I was interested in getting to dive into powerSHELL again. I’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. On reflection you wonder what is the point of these outside of Media files where they are used extensively. In the end I will stick with my FileSaveLaunch program but I may manually tag a few important files using File Manager to add them. What I thought would be something reasonably easy ended up being an interesting journey but with a disappointing end.