-
-
Notifications
You must be signed in to change notification settings - Fork 39
Real world examples
You may want to rename music files in one folder with meaningful and identifiable title or you may want to organise them by album or artist. With F2, this task is so easy because it allows you to utilise ID3 tags in the new file name. In this example, we'll organise the audio files in a folder into the following directory structure: artist/album/track
.
First, let's see the current state of the working directory:
As you can see, we have both mp3 and m4a files from different artists in the same folder. ID3 tags are supported for both formats (and more), so we'll go ahead and use it to structure the files in the desired order:
$ f2 -f '(\d+).*' -r '{{id3.artist}}/{{id3.album}}/$1-{{id3.title}}{{ext}}'
+--------------------------------------+-------------------------------------------------------------------+--------+
| INPUT | OUTPUT | STATUS |
+--------------------------------------+-------------------------------------------------------------------+--------+
| 13. Note To Self.mp3 | J. Cole/2014 Forest Hills Drive/13-Note to Self.mp3 | ok |
| 12. Love Yourz.mp3 | J. Cole/2014 Forest Hills Drive/12-Love Yourz.mp3 | ok |
| 11. Apparently.mp3 | J. Cole/2014 Forest Hills Drive/11-Apparently.mp3 | ok |
| 10. Hello.mp3 | J. Cole/2014 Forest Hills Drive/10-Hello.mp3 | ok |
| 09. No Role Modelz.mp3 | J. Cole/2014 Forest Hills Drive/09-No Role Modelz.mp3 | ok |
| 08. G.O.M.D.mp3 | J. Cole/2014 Forest Hills Drive/08-G.O.M.D..mp3 | ok |
| 05. A Tale of 2 Citiez.mp3 | J. Cole/2014 Forest Hills Drive/05-A Tale of 2 Citiez.mp3 | ok |
| 04. 03' Adolescence.mp3 | J. Cole/2014 Forest Hills Drive/04-03' Adolescence.mp3 | ok |
| 03. Wet Dreamz.mp3 | J. Cole/2014 Forest Hills Drive/03-Wet Dreamz.mp3 | ok |
| 02. January 28th.mp3 | J. Cole/2014 Forest Hills Drive/02-January 28th.mp3 | ok |
| 01. Intro.mp3 | J. Cole/2014 Forest Hills Drive/01-Intro.mp3 | ok |
| 10. 4 Your Eyez Only.mp3 | J. Cole/4 Your Eyez Only/10-4 Your Eyez Only.mp3 | ok |
| 09. She's Mine, Pt. 2.mp3 | J. Cole/4 Your Eyez Only/09-She's Mine, Pt. 2.mp3 | ok |
| 08. Foldin Clothes.mp3 | J. Cole/4 Your Eyez Only/08-Foldin Clothes.mp3 | ok |
| 07. Neighbors.mp3 | J. Cole/4 Your Eyez Only/07-Neighbors.mp3 | ok |
| 06. Change.mp3 | J. Cole/4 Your Eyez Only/06-Change.mp3 | ok |
| 05. She's Mine, Pt. 1.mp3 | J. Cole/4 Your Eyez Only/05-She's Mine, Pt. 1.mp3 | ok |
| 04. Ville Mentality.mp3 | J. Cole/4 Your Eyez Only/04-Ville Mentality.mp3 | ok |
| 03. Deja Vu.mp3 | J. Cole/4 Your Eyez Only/03-Deja Vu.mp3 | ok |
| 02. Immortal.mp3 | J. Cole/4 Your Eyez Only/02-Immortal.mp3 | ok |
| 01. For Whom The Bell Tolls.mp3 | J. Cole/4 Your Eyez Only/01-For Whom the Bell Tolls.mp3 | ok |
| 14 Goner.m4a | twenty one pilots/Blurryface/14-Goner.m4a | ok |
| 13 Not Today.m4a | twenty one pilots/Blurryface/13-Not Today.m4a | ok |
| 12 Hometown.m4a | twenty one pilots/Blurryface/12-Hometown.m4a | ok |
| 11 Message Man.m4a | twenty one pilots/Blurryface/11-Message Man.m4a | ok |
| 10 We Don't Believe What's On TV.m4a | twenty one pilots/Blurryface/10-We Don't Believe What's on TV.m4a | ok |
| 09 Polarize.m4a | twenty one pilots/Blurryface/09-Polarize.m4a | ok |
| 08 Doubt.m4a | twenty one pilots/Blurryface/08-Doubt.m4a | ok |
| 07 The Judge.m4a | twenty one pilots/Blurryface/07-The Judge.m4a | ok |
| 06 Lane Boy.m4a | twenty one pilots/Blurryface/06-Lane Boy.m4a | ok |
| 05 Tear In My Heart.m4a | twenty one pilots/Blurryface/05-Tear in My Heart.m4a | ok |
| 04 Fairly Local.m4a | twenty one pilots/Blurryface/04-Fairly Local.m4a | ok |
| 03 Ride.m4a | twenty one pilots/Blurryface/03-Ride.m4a | ok |
| 02 Stressed Out.m4a | twenty one pilots/Blurryface/02-Stressed Out.m4a | ok |
| 01 Heavydirtysoul.m4a | twenty one pilots/Blurryface/01-Heavydirtysoul.m4a | ok |
+--------------------------------------+-------------------------------------------------------------------+--------+
Append the -x flag to apply the above changes
Notice how the ID3 tags are used in the replacement string to organise the files in the desired order. The presence of the path separator (/
) will cause the directory components in the output to be auto created once the changes are committed to the filesystem. Let's go ahead and do just that:
$ f2 -f '(\d+).*' -r '{{id3.artist}}/{{id3.album}}/$1-{{id3.title}}{{ext}}' -x
Here's the result: