Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230
Renaming files in directory A with filenames in directory B
Renaming files in directory A with filenames in directory B
I have two versions of an album in two directories. The first contains files in .mp3 format.
The second contains the same tracks in .flac format.
The mp3 files are older and I have already renamed them to fit my preferred system.
I now want to switch to using .flac files but do not want to retype (or copy one by one) the filename from one directory to the other.
For example:
daud@debian:~/Music/Blues/ElmoreJames/Disc2$ ls -lh
-rw-r--r-- 1 daud daud 6.5M Sep 14 2020 01_2_TheSunIsShining.mp3
-rw-r--r-- 1 daud daud 5.4M Sep 14 2020 02_2_ICantHoldOut.mp3
-rw-r--r-- 1 daud daud 5.8M Sep 14 2020 03_2_StormyMondayBlues.mp3
...
drwxr-xr-x 2 daud daud 4.0K Jul 21 15:29 flac
daud@debian:~/Music/Blues/ElmoreJames/Disc2/flac$ ls -lh
-rw-r--r-- 1 daud daud 12M Jul 21 14:17 01 - The Sun Is Shining.flac
-rw-r--r-- 1 daud daud 9.7M Jul 21 14:18 02 - I Can't Hold Out.flac
-rw-r--r-- 1 daud daud 11M Jul 21 14:17 03 - Stormy Monday Blues.flac
...
The desired outcome would be:
daud@debian:~/Music/Blues/ElmoreJames/KingOfTheSlideGuitar/Disc2/flac$ ls -lh
-rw-r--r-- 1 daud daud 12M Jul 21 14:17 01_2_TheSunIsShining.flac
-rw-r--r-- 1 daud daud 9.7M Jul 21 14:18 02_2_ICantHoldOut.flac
-rw-r--r-- 1 daud daud 11M Jul 21 14:17 03_2_StormyMondayBlues.flac
a. Can anyone kindly show me how to achieve this (explicitly)?
b. Can anyone point me to an elementary source where I can learn to do this and other "filename manipulation" tasks.
Thanks
D2
The second contains the same tracks in .flac format.
The mp3 files are older and I have already renamed them to fit my preferred system.
I now want to switch to using .flac files but do not want to retype (or copy one by one) the filename from one directory to the other.
For example:
daud@debian:~/Music/Blues/ElmoreJames/Disc2$ ls -lh
-rw-r--r-- 1 daud daud 6.5M Sep 14 2020 01_2_TheSunIsShining.mp3
-rw-r--r-- 1 daud daud 5.4M Sep 14 2020 02_2_ICantHoldOut.mp3
-rw-r--r-- 1 daud daud 5.8M Sep 14 2020 03_2_StormyMondayBlues.mp3
...
drwxr-xr-x 2 daud daud 4.0K Jul 21 15:29 flac
daud@debian:~/Music/Blues/ElmoreJames/Disc2/flac$ ls -lh
-rw-r--r-- 1 daud daud 12M Jul 21 14:17 01 - The Sun Is Shining.flac
-rw-r--r-- 1 daud daud 9.7M Jul 21 14:18 02 - I Can't Hold Out.flac
-rw-r--r-- 1 daud daud 11M Jul 21 14:17 03 - Stormy Monday Blues.flac
...
The desired outcome would be:
daud@debian:~/Music/Blues/ElmoreJames/KingOfTheSlideGuitar/Disc2/flac$ ls -lh
-rw-r--r-- 1 daud daud 12M Jul 21 14:17 01_2_TheSunIsShining.flac
-rw-r--r-- 1 daud daud 9.7M Jul 21 14:18 02_2_ICantHoldOut.flac
-rw-r--r-- 1 daud daud 11M Jul 21 14:17 03_2_StormyMondayBlues.flac
a. Can anyone kindly show me how to achieve this (explicitly)?
b. Can anyone point me to an elementary source where I can learn to do this and other "filename manipulation" tasks.
Thanks
D2
Re: Renaming files in directory A with filenames in directory B
XFCE's Bulk Renamer can easily achieve this. There are probably more tools, but as XFCE user, this is the one quickly coming to my mind: https://docs.xfce.org/xfce/thunar/4.10/ ... amer/start
ThinkPad X220: i5-2520M CPU 2.5GHz - 8GB RAM 1333 MHz - SSD 860 EVO 250GB - Debian - ME_cleaned
ThinkPad X230: i5-3320M CPU 3.3GHz - 8GB RAM 1600 MHz - SSD 860 EVO 500GB - Debian - ME_cleaned
ThinkPad X230: i5-3320M CPU 3.3GHz - 8GB RAM 1600 MHz - SSD 860 EVO 500GB - Debian - ME_cleaned
Re: Renaming files in directory A with filenames in directory B
Thx for your response.esp7 wrote: ↑2021-07-21 17:47 XFCE's Bulk Renamer can easily achieve this. There are probably more tools, but as XFCE user, this is the one quickly coming to my mind: https://docs.xfce.org/xfce/thunar/4.10/ ... amer/start
I am familiar with Thunar's Bulk Renamer and use it regularly.
However, I have not been able to find a way to have it read the filenames (but not extensions) in one directory and apply them to files in another directory.
What I suppose I need is a script using sed and/or awk and regexes/other variables to parse a filename and feed it to mv/rename/a.n.other.
I do not currently have the skills to write this.
Furthermore, I have been unable to formulate a query for DDG or Google that produces answers other than how to (bulk) rename files.
- sunrat
- Administrator
- Posts: 6510
- Joined: 2006-08-29 09:12
- Location: Melbourne, Australia
- Has thanked: 118 times
- Been thanked: 487 times
Re: Renaming files in directory A with filenames in directory B
Are your flac files properly tagged? I use EasyTAG to rename files using their tags.
It can also rename files from a text file of filenames. You could create a text file from the mp3s with or if there are other files in the directory, filter mp3s with grep:
Name of the text file doesn't matter. In EasyTAG from the menu bar, Miscellaneous > Load Filenames From a Text File... . Then use a for loop to change "mp3" to "flac":
Or use a rename utility to change "mp3" to "flac". I don't use Xfce but the Bulk Renamer in Double Commander file manager functions similarly. Double Commander is quite light and useful for other tasks as well.
It can also rename files from a text file of filenames. You could create a text file from the mp3s with
Code: Select all
ls > filenames.txt
Code: Select all
ls |grep mp3 > filenames.txt
Code: Select all
for i in *.mp3; do mv -- "$i" "${i%.mp3}.flac"; done
“ computer users can be divided into 2 categories:
Those who have lost data
...and those who have not lost data YET ” Remember to BACKUP!
Those who have lost data
...and those who have not lost data YET ” Remember to BACKUP!
SOLVED Re: Renaming files in directory A with filenames in directory B
Thx sunrat. This seems to work OK.sunrat wrote: ↑2021-07-21 23:55 Are your flac files properly tagged? I use EasyTAG to rename files using their tags.
It can also rename files from a text file of filenames. You could create a text file from the mp3s withor if there are other files in the directory, filter mp3s with grep:Code: Select all
ls > filenames.txt
Name of the text file doesn't matter. In EasyTAG from the menu bar, Miscellaneous > Load Filenames From a Text File... . Then use a for loop to change "mp3" to "flac":Code: Select all
ls |grep mp3 > filenames.txt
Or use a rename utility to change "mp3" to "flac". I don't use Xfce but the Bulk Renamer in Double Commander file manager functions similarly. Double Commander is quite light and useful for other tasks as well.Code: Select all
for i in *.mp3; do mv -- "$i" "${i%.mp3}.flac"; done
(If you strip the (e.g.) .mp3 extension from the listed filenames in the text file, there is no need to rename the output files)
I've been using puddletag for audio file tagging.
It seems less intrusive than Easytag but lacks a file renaming function, so far as I can see.
- sunrat
- Administrator
- Posts: 6510
- Joined: 2006-08-29 09:12
- Location: Melbourne, Australia
- Has thanked: 118 times
- Been thanked: 487 times
Re: SOLVED Re: Renaming files in directory A with filenames in directory B
Good idea. You could add another pipe to sed to do it with a single command then:
Code: Select all
ls |grep mp3 | sed s/.mp3//g > filenames.txt
What do you mean by "intrusive"? I've used Easytag for many years and once you get used to its quirks it is ... easy!I've been using puddletag for audio file tagging.
It seems less intrusive than Easytag but lacks a file renaming function, so far as I can see.
![Very Happy :D](./images/smilies/icon_biggrin.gif)
“ computer users can be divided into 2 categories:
Those who have lost data
...and those who have not lost data YET ” Remember to BACKUP!
Those who have lost data
...and those who have not lost data YET ” Remember to BACKUP!
Re: SOLVED Re: Renaming files in directory A with filenames in directory B
<<snip>>
[/quote]
What do you mean by "intrusive"? I've used Easytag for many years and once you get used to its quirks it is ... easy!![Very Happy :D](./images/smilies/icon_biggrin.gif)
[/quote]
Poor word choice? I simply meant that EasyTag seems to spend a longgggg time searching for and (?) indexing files. (I have quite a few for it to look through).
As for the quirks, well yes it was easy enough, but I succeeded with renaming the files in the first directory almost entirely without knowing at which stage the name changes are actually applied and saved. I'm still not sure - I'll bet there's a better way than trying to quit the program and saving when it complains. Anyway, it worked, thank you, and I'll persevere to see if I can make better sense of EasyTag's idiosyncracies.
[/quote]
What do you mean by "intrusive"? I've used Easytag for many years and once you get used to its quirks it is ... easy!
![Very Happy :D](./images/smilies/icon_biggrin.gif)
[/quote]
Poor word choice? I simply meant that EasyTag seems to spend a longgggg time searching for and (?) indexing files. (I have quite a few for it to look through).
As for the quirks, well yes it was easy enough, but I succeeded with renaming the files in the first directory almost entirely without knowing at which stage the name changes are actually applied and saved. I'm still not sure - I'll bet there's a better way than trying to quit the program and saving when it complains. Anyway, it worked, thank you, and I'll persevere to see if I can make better sense of EasyTag's idiosyncracies.
- sunrat
- Administrator
- Posts: 6510
- Joined: 2006-08-29 09:12
- Location: Melbourne, Australia
- Has thanked: 118 times
- Been thanked: 487 times
Re: SOLVED Re: Renaming files in directory A with filenames in directory B
Ah yes, that's one of its quirks. If you just open Easytag it will index every directory under the one you have set in Preferences for it to open initially. You can change that preference to just your music directory. The quickest way to open it is to right-click on a music file and select "Open With Easytag", then it will only index that directory and ones beneath it.dauddaud1 wrote: ↑2021-07-22 23:45Poor word choice? I simply meant that EasyTag seems to spend a longgggg time searching for and (?) indexing files. (I have quite a few for it to look through).What do you mean by "intrusive"? I've used Easytag for many years and once you get used to its quirks it is ... easy!![]()
“ computer users can be divided into 2 categories:
Those who have lost data
...and those who have not lost data YET ” Remember to BACKUP!
Those who have lost data
...and those who have not lost data YET ” Remember to BACKUP!
Re: Renaming files in directory A with filenames in directory B
Ex Falso is more efficient if you ask me.
ThinkPad X220: i5-2520M CPU 2.5GHz - 8GB RAM 1333 MHz - SSD 860 EVO 250GB - Debian - ME_cleaned
ThinkPad X230: i5-3320M CPU 3.3GHz - 8GB RAM 1600 MHz - SSD 860 EVO 500GB - Debian - ME_cleaned
ThinkPad X230: i5-3320M CPU 3.3GHz - 8GB RAM 1600 MHz - SSD 860 EVO 500GB - Debian - ME_cleaned
Re: SOLVED Re: Renaming files in directory A with filenames in directory B
I also used Easytag years ago, but it got so bloated, that it came unusable with my old notebooks.sunrat wrote: ↑2021-07-23 03:08
Ah yes, that's one of its quirks. If you just open Easytag it will index every directory under the one you have set in Preferences for it to open initially. You can change that preference to just your music directory. The quickest way to open it is to right-click on a music file and select "Open With Easytag", then it will only index that directory and ones beneath it.
I've found lltag (Debian package lltag) nice http://bgoglin.free.fr/lltag/ A cli program. Also use cmus to listen music
![Very Happy :D](./images/smilies/icon_biggrin.gif)