How to create a shortcut file to a physical file?

There was a user request ...
Copying shortcuts to files
... for creating a shortcut file within a new folder, targetting a real file anywhere else on the disk. Such a feature would allow to create a "virtual catalog" or an user defined "view" to the existing file base. Yes, the effect is something like a m3u file could deliver too.

Mp3tag has no built in feature to create link files from real files yet.
But the idea sounds interesting, anyway, and I have tried something into this direction using the Mp3tag export feature.

I put together a Mp3tag export file, which creates a textual Visual Basic Script file.
A VBS script can run directly on a Windows operating system like a BAT or CMD script, when the Windows Script Host (WSH), a well known Windows administration tool, is installed.
The Windows Script Host is built into Microsoft Windows 98 and later versions of Microsoft Windows.
To upgrade to the latest version of Windows Script Host, search for "Windows Script Host" on the Microsoft Download Center.
You can determine your Windows Script Host version number by typing CScript at a command prompt.

The attached Mp3tag export script demonstrates how it could be realized to build a folder tree full of link files pointing to real files, still residing in there home folders.
Mp3tag provides the data and the Windows Shell does the filesystem job.

My proposal script will create a folder tree starting at a given root folder e. g. "O:\TEST\BPM".
Because of some quirks in the Mp3tag export scripting language, this root folder has to be defined respectively adapted in the export script at different places, see lines which contain "$puts(My_RootFolder,'...".

For each different BPM value in the group of selected tracks the script will create a new folder named by this specific BPM value, e. g. BPM value is 120, the folder is named to "BPM 120".
Within this folder there will be created a link file (or more), which points to the physical file with the correlating BPM value.
This way all files with the same BPM value, respectively their link files, will be aggregated into one folder. Note: This can only work successfully when each filename is unique!

When using additionally VB script code, it should be possible to ask the user for more input details or let pick the root folder by a standard Open Folder system dialog. This task is left to the user.

When Mp3tag has finished the "20100913.BuildCat_BPM.mte" export script, the result is a text file named "BuildCat_BPM.vbs".
If execution of VBS scripts is allowed on the system, then the VBS script can be executed automatically by answering "Yes" to the last export dialog ("show result").

20100913.BuildCat_BPM.mte (2.07 KB)

Edit. Small changes in the export script.

20100913.BuildCat_BPM.mte (2.07 KB)

Here comes an advanced script version 2.1 providing a "Browse For Folder" dialog.
Mp3tag export script file: BuildCat_BPM_2.1.mte

20100916.BuildCat_BPM_2.1.mte (4.66 KB)


20100916.BuildCat_BPM_2.1.mte (4.66 KB)

Thanks for sharing your code. It seems clear and well documented, even to a non-professional like me. I like how you used a popup message to indicate the progress of creating folders. I often wish VBS had some method to show a progress bar.

Here's a quote from you in another thread:

I agree. Your mte file is a good example that illustrates the potential. I may not need a folder full of short-cuts but your example provides an excellent template for creating other VBS scripts.
I'd like to try creating a multi-dimensional array that contains tag information gleaned from MP3Tag. Maybe it could be used for manipulating supported audio files.

Thanks again,

Jim, thank you for your kind words.
If I ever have given you a push into the direction of VBS and Mp3tag scripting, then go ahead and try it out what you are thinking about!



Here comes an advanced Mp3tag export script version 2.2, which demonstrates how to create a foldertree of genre related subfolders.

There is a new VBS dialog, which asks for suppressing of info details (e. g. creating of subfolder) in order to let the runtime of the created VBS script as short as possible.

Mp3tag export script file: BuildCat_GENRE_2.2.mte


There might exist GENRE tag-field content which looks like "Pop/Rock" or "Pop\Rock".
When using the "BuildCat_GENRE_2.2.mte" script such GENRE content will trigger the script to create additional subfolders under the main genre, for example, genre "Pop/Rock" will create a folder "Rock" within the folder "Pop":
--- "Rock"
This might be useful or not, who knows?

But there might exist GENRE tag-field content which looks like "Pop / Rock" or "Pop \ Rock", note the space characters around the slash delimiters.
Such genre tag-field content leads to bad circumstances in the file system, and can break the VBS script with error code 80070003 and error message like "Link cannot be saved".

To avoid such problems I have changed the specific script line ...
from ...
'Mp3tag_SubfolderNew = "'$if2($trim(%GENRE%),'_Unknown')'" & ""'
to ...
'Mp3tag_SubfolderNew = "'$if2($trim($validate(%GENRE%,'-')),'_Unknown')'" & ""'

This will create "Pop-Rock" or "Pop - Rock" genre folders and avoids the creation of further subfolders.



Here comes a fresh version of "20100920.BuildCat_GENRE.3.0.mte".

This Mp3tag export script generates smaller VBS script output than versions before, because of the usage of functions and procedures.

When the VBS script is running, now the user has the choice to see info details or not or break the running process.


New version "20100922.BuildCat_GENRE.3.1.mte".
Now smaller VBS script output than versions before.
Now more info details.

20100922.BuildCat_GENRE.3.1.mte (13.3 KB)


20100922.BuildCat_GENRE.3.1.mte (13.3 KB)