# Fully qualified versus relative path in format string

**URL:** <https://community.mp3tag.de/t/fully-qualified-versus-relative-path-in-format-string/61240>\
**Category:** Support\
**Created:** [June 11, 2023, 5:11pm UTC](https://community.mp3tag.de/t/fully-qualified-versus-relative-path-in-format-string/61240 "2023-06-11T17:11:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rayw](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/r/3d9bf3/32.png) [@rayw](https://community.mp3tag.de/u/rayw)\
**Post date:** [June 11, 2023, 5:11pm UTC](https://community.mp3tag.de/t/fully-qualified-versus-relative-path-in-format-string/61240/1 "2023-06-11T17:11:14Z")

</div>

I'm trying to move files to folders based on artist and album names but the new filename is always relative to the current file location and not a fully qualified path from the root of the drive. Assuming that files will be moved from and to the same drive is acceptable. My file structure is:

\  
.....My Music\  
..........Album Artist 1\  
...............(Year) Album A\  
....................Track - Title.mp3  
..........John E. Guitarplayer\  
...............(2023) Hit Songs\  
....................001 - Happy Song.mp3  
..........Album Artist 3\  
...............(Year) Album C\  
....................Track - Title.mp3  
..........Unsorted Tracks\  
...............Title.mp3  
..........Other files\  
...............New Music Files\  
....................Target File.mp3

I use mp3tag to load correct tag information then use a format string to rename and move the files to appropriate folders:

Current Directory: G:\My Music\Other Files\New Music Files  
File: Target File.mp3  
AlbumArtist: John E. Guitarplayer  
Year: 2023  
Album: Hit Songs  
Track: 002  
Title: Sad Song

\My Music%albumartist%(%year%) %album%$num(%track%,3) - %title%

I'm expecting to get:

\  
.....My Music\  
..........John E. Guitarplayer\  
...............(2023) Hit Songs\  
....................001 - Happy Song.mp3  
....................002 - Sad Song.mp3  
..........Other files\  
...............New Music Files\

Instead, I get:

\  
.....My Music\  
..........John E. Guitarplayer\  
...............(2023) Hit Songs\  
....................001 - Happy Song.mp3  
..........Other files\  
...............New Music Files\  
....................My Music\  
.........................John E. Guitarplayer\  
..............................(2023) Hit Songs\  
...................................002 - Sad Song.mp3

A new path is created in the original folder even though my format string begins with a backslash. It works the same with or without the leading backslash.

This works fine if I specify the drive letter:

G:\My Music%albumartist%(%year%) %album%$num(%track%,3) - %title%

But I can't be sure what letter Windows might assign each time I mount a removeable drive. Is there a way to reference the "current drive" in a format string?

This also works but I'd have to assume I'd never be more than 10 levels deep in the file structure:

....................\My Music%albumartist%(%year%) %album%$num(%track%,3) - %title%

It's not very elegant but gets the job done until I find myself 11 or more levels deep. Then, God knows where the file may be relocated to. Is there a better way to handle this?

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [June 11, 2023, 5:18pm UTC](https://community.mp3tag.de/t/fully-qualified-versus-relative-path-in-format-string/61240/2 "2023-06-11T17:18:29Z")

</div>

> [@rayw](#):
>
> But I can't be sure what letter Windows might assign each time I mount a removeable drive. Is there a way to reference the "current drive" in a format string?

You could retrieve that letter plus the colon with  
`$left(%_path%,2)`

---

<div class="post-metadata">

**Author:** ![rayw](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/r/3d9bf3/32.png) [@rayw](https://community.mp3tag.de/u/rayw)\
**Post date:** [June 11, 2023, 5:39pm UTC](https://community.mp3tag.de/t/fully-qualified-versus-relative-path-in-format-string/61240/3 "2023-06-11T17:39:19Z")

</div>

That works. Thanks. I guess there's no way to just refer to the root of the current drive?

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [June 11, 2023, 5:45pm UTC](https://community.mp3tag.de/t/fully-qualified-versus-relative-path-in-format-string/61240/4 "2023-06-11T17:45:28Z")

</div>

Show me a way with OS means or the command line syntax and that would be the solution.  
I wonder why that short piece of scripting isn't fit for your special requirements.  
BTW: if you assign a drive letter manually, then Windows usually remembers that. It should be a letter that is usually not reached by the automatic drive letter assignment, e.g. `J` would be a letter that is probably not used by USB devices.  
So your external drive should be registered by its hardware identifier and then always get the same drive letter.

---

<div class="post-metadata">

**Author:** ![rayw](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/r/3d9bf3/32.png) [@rayw](https://community.mp3tag.de/u/rayw)\
**Post date:** [June 11, 2023, 6:40pm UTC](https://community.mp3tag.de/t/fully-qualified-versus-relative-path-in-format-string/61240/5 "2023-06-11T18:40:01Z")

</div>

> [@ohrenkino](#):
>
> Show me a way with OS means or the command line syntax and that would be the solution.  
> I wonder why that short piece of scripting isn't fit for your special requirements.

That code does work. I was just thinking in terms of the commands mkdir, chdir and rmdir and how the leading backslash on a directory name determines where the action occurs. No matter where I am on a drive, the command

> md \newfolder

will create a new directory named newfolder in the root of the drive while

> md newfolder

will create a new directory IN the current directory. I don't know how that relates to the scripting engine in mp3tag but that's where I was coming from. $left(%\_path%,2) works fine and I've already added it to my format strings. So thanks again for that.

---

<div class="post-metadata">

**Author:** ![system](https://community.mp3tag.de/uploads/default/original/2X/c/ce7035d426cb755a7916793326d23b465222a407.png) [@system](https://community.mp3tag.de/u/system)\
**Post date:** [July 11, 2023, 6:40pm UTC](https://community.mp3tag.de/t/fully-qualified-versus-relative-path-in-format-string/61240/6 "2023-07-11T18:40:13Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
