# One for the archives. Where are the archives?

**URL:** <https://community.mp3tag.de/t/one-for-the-archives-where-are-the-archives/52048>\
**Category:** Web Sources Discussion\
**Created:** [February 19, 2021, 8:02pm UTC](https://community.mp3tag.de/t/one-for-the-archives-where-are-the-archives/52048 "2021-02-19T20:02:07Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![tnbnicer](https://community.mp3tag.de/user_avatar/community.mp3tag.de/tnbnicer/32/8916_2.png) [@tnbnicer](https://community.mp3tag.de/u/tnbnicer)\
**Post date:** [February 19, 2021, 8:02pm UTC](https://community.mp3tag.de/t/one-for-the-archives-where-are-the-archives/52048/1 "2021-02-19T20:02:07Z")

</div>

Hi \>

I devised a Powershell script to add tags. It's been done before, I know, but where is a good place to post it in the spirit of sharing?

It wasn't easy to figure out how to use Powershell scriptlets via Mp3tag. There are few examples. (Or they're hidden away in a quiet corner someplace?) This could be one example.

The script runs from Tools. It depends on ffprobe (@ [ffmpeg.org](http://ffmpeg.org)) and Taglib library (@ github). You download/clone the Github repos, requiring a certain level of advanced 'know-how'. Anyway, nothing fancy. I use the script to write the number of samples in MP3s to an extended tag. You can change the lines of course to write other tags which are less available directly through Mp3tag.

What's the best practice for posting examples? Here?

---

<div class="post-metadata">

**Author:** ![MP3Freak\_Peter](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/c68b51/32.png) [@MP3Freak\_Peter](https://community.mp3tag.de/u/MP3Freak_Peter)\
**Post date:** [February 19, 2021, 9:01pm UTC](https://community.mp3tag.de/t/one-for-the-archives-where-are-the-archives/52048/2 "2021-02-19T21:01:00Z")

</div>

Hi & Welcome.

Simply post what you've created and an short tutorial how it works.  
Many Freaks and Nerds here 🙂 who can give some feedback.

Curious about how you use powershell scripts via mp3tag.

regards,  
Peter

---

<div class="post-metadata">

**Author:** ![tnbnicer](https://community.mp3tag.de/user_avatar/community.mp3tag.de/tnbnicer/32/8916_2.png) [@tnbnicer](https://community.mp3tag.de/u/tnbnicer)\
**Post date:** [February 19, 2021, 9:01pm UTC](https://community.mp3tag.de/t/one-for-the-archives-where-are-the-archives/52048/3 "2021-02-19T21:01:49Z")

</div>

I'll try this upload button to see where it uploads to.

[samples.zip](https://community.mp3tag.de/uploads/short-url/bki3tMaWeJ2gNg2KCJAt6XHrCES.zip) (2.6 KB)

re: "Don't forget to sign." Under most ExecutionPolicy settings, you must sign \*.ps1 files in order for them to run on Windows. I left my digital signature at the bottom. Please remove it before testing the script. Thanks.

Any questions, comments, you know where to find me. (Hope the link works.)

---

<div class="post-metadata">

**Author:** ![tnbnicer](https://community.mp3tag.de/user_avatar/community.mp3tag.de/tnbnicer/32/8916_2.png) [@tnbnicer](https://community.mp3tag.de/u/tnbnicer)\
**Post date:** [February 19, 2021, 9:04pm UTC](https://community.mp3tag.de/t/one-for-the-archives-where-are-the-archives/52048/4 "2021-02-19T21:04:40Z")

</div>

> [@MP3Freak\_Peter](#):
>
> Curious about how you use powershell scripts via mp3tag.

Yes, how to link Powershell scripts with a commandline. A difficult one.

---

<div class="post-metadata">

**Author:** ![MP3Freak\_Peter](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/c68b51/32.png) [@MP3Freak\_Peter](https://community.mp3tag.de/u/MP3Freak_Peter)\
**Post date:** [February 19, 2021, 9:13pm UTC](https://community.mp3tag.de/t/one-for-the-archives-where-are-the-archives/52048/5 "2021-02-19T21:13:40Z")

</div>

I'm just reading the script ...  
well... to many hardcoded path information, you should define an configuration section.  
If you need an working path, you should not hardcode. how about creating an subdirectory in %temp% ?

---

<div class="post-metadata">

**Author:** ![tnbnicer](https://community.mp3tag.de/user_avatar/community.mp3tag.de/tnbnicer/32/8916_2.png) [@tnbnicer](https://community.mp3tag.de/u/tnbnicer)\
**Post date:** [February 19, 2021, 9:27pm UTC](https://community.mp3tag.de/t/one-for-the-archives-where-are-the-archives/52048/6 "2021-02-19T21:27:59Z")

</div>

You mean like Boccherini? That's true.

ffmpeg/ffprobe is in the environment path on my system, but it still won't run from Mp3tag, unless you assign an alias, hence the line `set-alias ffprobe "G:\Install Programs\CD & DVD\ffmpeg\ffmpeg-2021-02-16-git-8331eb058d-full_build\bin\ffprobe.exe"`

Where anyone saves their Github repositories is a personal choice. The hard part is cloning a repo in the first place, in my view. I could remove the path, and leave a blank in square brackets instead. I think though that if you've gone to the trouble to install a Github repo, changing the path is a small matter. Using this script might take about an hour of preparation for someone who hasn't installed `ffprobe.exe` or `taglib-sharp.dll`.

Is it worth it? I believe so, if you have a lot of x-tra tags and so forth. You can insert them on the fly.

---

<div class="post-metadata">

**Author:** ![tnbnicer](https://community.mp3tag.de/user_avatar/community.mp3tag.de/tnbnicer/32/8916_2.png) [@tnbnicer](https://community.mp3tag.de/u/tnbnicer)\
**Post date:** [February 19, 2021, 9:36pm UTC](https://community.mp3tag.de/t/one-for-the-archives-where-are-the-archives/52048/7 "2021-02-19T21:36:26Z")

</div>

I can try to include a step-by-step guide in my next post, and take out some of the external paths ...

Might take 24 hours.

---

<div class="post-metadata">

**Author:** ![MP3Freak\_Peter](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/m/c68b51/32.png) [@MP3Freak\_Peter](https://community.mp3tag.de/u/MP3Freak_Peter)\
**Post date:** [February 19, 2021, 10:39pm UTC](https://community.mp3tag.de/t/one-for-the-archives-where-are-the-archives/52048/8 "2021-02-19T22:39:40Z")

</div>

take your time... don't rush

---

<div class="post-metadata">

**Author:** ![tnbnicer](https://community.mp3tag.de/user_avatar/community.mp3tag.de/tnbnicer/32/8916_2.png) [@tnbnicer](https://community.mp3tag.de/u/tnbnicer)\
**Post date:** [February 20, 2021, 5:57am UTC](https://community.mp3tag.de/t/one-for-the-archives-where-are-the-archives/52048/9 "2021-02-20T05:57:00Z")

</div>

Hi \>

Here is (supposed to be) a screen capture of the Tools menu. Shown are two Powershell tools.

![tools](https://community.mp3tag.de/uploads/default/original/2X/7/7a7ddca009d2ed759da8b379eaa8b9c9dd2afebc.jpeg) .

Configuring `Add Samples Tag` requires the following (Windows):

```
Name: Add Samples Tag
Path: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Parameter: -ExecutionPolicy Bypass -NoProfile -File "[path\to]\samples.ps1" -Path "%_folderpath%\"

```

Do not tick "for all selected files", as it’s unhealthy.

MP3s contained in the same folder and subfolders of the folder are simultaneously opened for tagging. That happens automatically when you right-click on a file that opens the context menu and click the `Add Samples Tag` tool.

Configure `Add Samples Tag (1 file only)`:

```
Name: Add Samples Tag (1 file only)
Path: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Parameter: -ExecutionPolicy Bypass -NoProfile -File "[path\to]\samples-for-one.ps1" -Path "%_folderpath%\" -filename "%_filename_ext%"

```

You can optionally tick "for all selected files". If you do so at your own peril, selected MP3s are tagged consecutively; a new window opens each time.

**Installation.**

Download from [ffmpeg.org](http://ffmpeg.org). Extract to a location of your choice.

Visit [GitHub - illearth/powershell-taglib: A PowerShell module for manipulating metadata in media files with TagLibSharp](https://github.com/illearth/powershell-taglib). Clone or download the Zip.

Edit the scripts `samples.ps1` and `samples-for-one.ps1` in a text editor.

Delete the signature blocks. I left them in place to illustrate what a signature will look like when you generate your own.

Input a valid default working folder. In `samples-for-one.ps1`, provide a default file. Default parameters serve as placeholders in the event that you wish to test run the scripts without a commandline, for example, so don't worry. Default MP3s won't be tagged while launching from Mp3tag, as long as the commandline includes the parameters that are processed.

You must provide the full path locations of `ffprobe.exe` and `taglib-sharp.dll` in your editor.

Once you finish editing, save the scripts.

Signing requires a code-signing certificate.

I utilize a small code for signing.

```
param([string] $file=$(throw "Please specify a filename."))
$cert = @(Get-ChildItem cert:\CurrentUser\TrustedPublisher -codesigning)[0]
Set-AuthenticodeSignature $file $cert

```

Run in Powershell:

`PS [path\to\code]> .\add-signature.ps1 [path\to]\script.ps1`

This adds the signature block authorizing Windows to execute a script.

Successful mp3tagging to all.

**Caution.**

If you already wrote a tag, a new tag is appended, the existing tag not overwritten. You'll end up with two (or three) tags. Mp3tag may show just one tag, but, trust me, there are two of the same name.

Deleting in Mp3tag removes both thankfully.

Do not attempt to remove redundant tags in a PS script requiring a library.

Metatags often reside inside category frames. Typically `taglib-sharp.dll` empties the frame, the entire category vanishes. Assuming you want to delete a specific tag, you should use Mp3tag for that purpose. It's designed for such tasks and has many additional beneficial traits as well.

The number of samples can be easily calculated as milliseconds and the value written to a \*.xspf playlist (Duration) created with a \*.mte script. Try it.

**Download tools.**

[samples.zip](https://community.mp3tag.de/uploads/short-url/oVY2Pg2UaQmALofc1CRLg6yPmuO.zip) (4.9 KB)

Contains `samples.ps1` and `samples-for-one.ps1`. (Thanks.)

What is a \*.xspf (spiff, for short) playlist? A playlist in Xml format. My Android gobbles them up.

Take a peek.

[mp3tag-s7.zip](https://community.mp3tag.de/uploads/short-url/w6k2ErrwmPJe4qg5cidQaPxq24o.zip) (1.3 KB)

---

<div class="post-metadata">

**Author:** ![tnbnicer](https://community.mp3tag.de/user_avatar/community.mp3tag.de/tnbnicer/32/8916_2.png) [@tnbnicer](https://community.mp3tag.de/u/tnbnicer)\
**Post date:** [February 21, 2021, 10:19am UTC](https://community.mp3tag.de/t/one-for-the-archives-where-are-the-archives/52048/10 "2021-02-21T10:19:32Z")

</div>

The \*.mte source, in case someone's interested.

[xspf\_vlc\_s7.zip](https://community.mp3tag.de/uploads/short-url/lqkDrBiC76kA2ETnSPo2kts4voR.zip) (2.2 KB)

It would be nice if Mp3tag featured URL-encode and Html-entity-encode as script functions, natively, like $char(). And as to milliseconds? Why not?

VLC kind of does not support embedded albumart. It's either or. A folder image or an embedded image. Having both screws VLC (phone and PC versions) up a little. Cached album images, whether from an embedded or a folder source, are a hassle to delete from a phone. Another reason to choose \*.xspf playlists. Image links are in the playlist, although, again, playlist links don't necessarily override embedded images. VLC gets really confused.

\*.xspf playlists are widely implemented, on a range of platforms and players (so I read). Not just VLC on Android gobbles them up.
