COMMENT
Music Tag Editor 1.1 - by e10withadot
Changes in this version:
* Multiple file support has been added! Now you can simultaneously modify the metadata of multiple files. Fields with more than one entry will show as “Multiple”.
* New main menu icons! They’re pink and full of style.
* You can now see a preview of a file’s album artwork from the main menu.
* Many comments are now spread throughout the shortcut, to explain the process of each batch of actions.
Allows exporting to M4A and AIFF formats.
Supported audio files shown below 👇
FILES
Filter
Shortcut Input
where
Any of the following are true [{'class': 'filter-property', 'value': 'File Extension'}, {'class': 'filter-operator', 'value': 'is'}, {'class': 'filter-benchmark', 'value': 'mp3'}] [{'class': 'filter-property', 'value': 'File Extension'}, {'class': 'filter-operator', 'value': 'is'}, {'class': 'filter-benchmark', 'value': 'aiff'}] [{'class': 'filter-property', 'value': 'File Extension'}, {'class': 'filter-operator', 'value': 'is'}, {'class': 'filter-benchmark', 'value': 'ogg'}] [{'class': 'filter-property', 'value': 'File Extension'}, {'class': 'filter-operator', 'value': 'is'}, {'class': 'filter-benchmark', 'value': 'wmv'}] [{'class': 'filter-property', 'value': 'File Extension'}, {'class': 'filter-operator', 'value': 'is'}, {'class': 'filter-benchmark', 'value': 'wma'}] [{'class': 'filter-property', 'value': 'File Extension'}, {'class': 'filter-operator', 'value': 'is'}, {'class': 'filter-benchmark', 'value': 'aac'}] [{'class': 'filter-property', 'value': 'File Extension'}, {'class': 'filter-operator', 'value': 'is'}, {'class': 'filter-benchmark', 'value': 'flac'}] [{'class': 'filter-property', 'value': 'File Extension'}, {'class': 'filter-operator', 'value': 'is'}, {'class': 'filter-benchmark', 'value': 'm4a'}] [{'class': 'filter-property', 'value': 'File Extension'}, {'class': 'filter-operator', 'value': 'is'}, {'class': 'filter-benchmark', 'value': 'alac'}] [{'class': 'filter-property', 'value': 'File Extension'}, {'class': 'filter-operator', 'value': 'is'}, {'class': 'filter-benchmark', 'value': 'm4b'}] [{'class': 'filter-property', 'value': 'File Extension'}, {'class': 'filter-operator', 'value': 'is'}, {'class': 'filter-benchmark', 'value': 'mp4'}] [{'class': 'filter-property', 'value': 'File Extension'}, {'class': 'filter-operator', 'value': 'is'}, {'class': 'filter-benchmark', 'value': 'wav'}] [{'class': 'filter-property', 'value': 'File Extension'}, {'class': 'filter-operator', 'value': 'is'}, {'class': 'filter-benchmark', 'value': 'aif'}] [{'class': 'filter-property', 'value': 'File Extension'}, {'class': 'filter-operator', 'value': 'is'}, {'class': 'filter-benchmark', 'value': 'aifc'}]

Files
COMMENT
👇 Error message for non-media files.
SCRIPTING
If
Media
does not have any value
SCRIPTING
Show alert
No audio files found.
Title
No audio files found.
SCRIPTING
Exit shortcut with
Result
SCRIPTING
End If

If Result
SCRIPTING
Repeat with each item in
Media

Repeat Results
COMMENT
The album artwork is encoded in base64 for storage in a json file.
MEDIA
Resize
Repeat Item
to
640
x
Auto Height

Resized Image
SCRIPTING
Encode
Resized Image
with base64

Base64 Encoded
COMMENT
The 6 starting keys in the metadata json base are spelled exactly like the menu options, for cleaner association.
DICTIONARY

Dictionary
COMMENT
The Tracks variable is a backup for lost metadata.
VARIABLES
Add
Repeat Dictionary
to
Tracks
SCRIPTING
If
Repeat Index
is greater than or equal to
2
SCRIPTING
Repeat
6 times

Repeat Results
COMMENT
This is a check for metadata fields that don’t match previous files.
COMMENT
All the fields are listed here so the Repeat cycles between them using the Repeat Index.
LIST

List
SCRIPTING
Get
Item At Index
Repeat Index 2
from
List

Item from List
COMMENT
The shortcut grabs the values for the current key, of both the current metadata and the previously used metadata.
SCRIPTING
Get
Value
for
Current Key
in
Repeat Dictionary

Dictionary Value
SCRIPTING
Get
Value
for
Current Key
in
Former Item

Dictionary Value
SCRIPTING
If
Dictionary Value
is
Dictionary Value
COMMENT
If both metadata fields are identical, it outputs the metadata field.
TEXT
Dictionary Value

Text
SCRIPTING
Otherwise
COMMENT
If the metadata fields aren’t identical, it outputs “Multiple”.
TEXT
Multiple

Text
SCRIPTING
End If

If Result
COMMENT
The modified value is saved in the Metadata variable at the correct key.
SCRIPTING
Set
Current Key
to
Current Value
in
Dictionary

Dictionary
VARIABLES
Set variable
Metadata
to
Dictionary
SCRIPTING
End Repeat

Repeat Results
SCRIPTING
Otherwise
COMMENT
For the first item, the metadata is outright saved in the Metadata variable.
VARIABLES
Set variable
Metadata
to
Repeat Dictionary
SCRIPTING
End If

If Result
VARIABLES
Set variable
Former Item
to
Metadata
SCRIPTING
End Repeat

Repeat Results
MISSING
calculateexpression Under Construction
SCRIPTING
Repeat
Calculation Result

Repeat Results
COMMENT
The following code is a method for creating shortcut menus with icons and descriptions- discovered by pfg, at https://routinehub.co/shortcut/1138.
SCRIPTING
Count
Characters
in
Metadata

Count
SCRIPTING
If
Count
is greater than
2
SCRIPTING
Get
Value
for
Album Art
in
Metadata

Dictionary Value
SCRIPTING
If
Dictionary Value
is not
Multiple
SCRIPTING
Decode
Metadata
with base64

Base64 Encoded
COMMENT
Album Artwork is resized to 82x82 for the menu preview.
MEDIA
Resize
Base64 Encoded
to
82
x
Auto Height

Resized Image
SCRIPTING
Mode
Resized Image
with base64

Base64 Encoded
COMMENT
Menu when multiple Album Art is available.

Text
SCRIPTING
Otherwise
COMMENT
Menu when a single Album Artwork is available.

Text
SCRIPTING
End If

If Result
SCRIPTING
Otherwise
COMMENT
Menu when no Album Art is available.

Text
SCRIPTING
End If

If Result
SCRIPTING
Set name of
If Result
to
menu.vcf

Renamed Item
SCRIPTING

Chosen Item
COMMENT
The chosen key was saved as a variable because I got tired of scrolling up.
VARIABLES
Set variable
Key
to
Key
COMMENT
The output process.
SCRIPTING
If
Key
is
Save
SCRIPTING
Repeat with each item in
Media

Repeat Results
VARIABLES
Set variable
Output
to
Metadata
SCRIPTING
Get
Item At Index
Repeat Index 2
from
Tracks

Item from List
COMMENT
In this Repeat action, the shortcut restores metadata fields that weren’t synonomyous, using the Tracks variable.
SCRIPTING
Repeat
6 times

Repeat Results
LIST

List
SCRIPTING
Get
Item At Index
Repeat Index 3
from
List

Item from List
SCRIPTING
Get
Value
for
Current Key 2
in
Output

Dictionary Value
SCRIPTING
If
Universal Value
is
Multiple
COMMENT
If the field inputs “Multiple”, the shortcut gets the value from the Tracks variable.
SCRIPTING
Get
Value
for
Current Key 2
in
Current Track

Dictionary Value
SCRIPTING
Otherwise
COMMENT
If the field inputs anything else, the shortcut gets the value from the Metadata variable.
VARIABLES
Get
Universal Value
SCRIPTING
End If

If Result
SCRIPTING
Set
Current Key 2
to
If Result
in
Dictionary

Dictionary
VARIABLES
Set variable
Output
to
Dictionary
SCRIPTING
End Repeat

Repeat Results
SCRIPTING
Decode
Output
with base64

Base64 Encoded
VARIABLES
Set variable
Album Art
to
Base64 Encoded
COMMENT
The Output variable is placed in the metadata section, with the keys labeled according to their subcategory.
MEDIA
Encode
Repeat Item 2
Options Under Construction

Encoded Media
SCRIPTING
End Repeat

Repeat Results
DOCUMENTS

Saved File
SCRIPTING
Exit shortcut with
Result
SCRIPTING
End If

If Result
COMMENT
The Input Zone.
SCRIPTING
If
Key
is not
Album Art
SCRIPTING
If
Key
is not
Year
COMMENT
Entering inputs for text-based metadata fields (Title, Album, Artist, Genre).
SCRIPTING
Get
Value
for
Key
in
Metadata

Dictionary Value
SCRIPTING
If
Dictionary Value
is
Multiple