LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   massive rename of songs; normalize song filename convert foriegn to english character (https://www.linuxquestions.org/questions/linux-general-1/massive-rename-of-songs%3B-normalize-song-filename-convert-foriegn-to-english-character-929320/)

ununun 02-14-2012 12:17 PM

massive rename of songs; normalize song filename convert foriegn to english character
 
i have about 35k songs. some of them have foregin character like (¶,ö) in their filename. and some players like clementine, gmusicbrowser wont detect these songs.

so i need help to replace those forign char into their respective english char.

thanks

sys64738 02-14-2012 05:00 PM

Hi
I've found the following: http://gordonazmo.wordpress.com/2011...from-filename/

I would change it a bit to work on nested folders and to test if it works for you:
Code:

find /path/to/files -type f -print | grep [ÄÖÜäöü߶] | while read file; do N=$(echo $file | tr -cd '\11\12\40-\176'); echo mv "$file" "$N"; done
The output will show the files (filenames) to be changed.
If you are satisfied with the result do:
Code:

find /path/to/files -type f -print | grep [ÄÖÜäöü߶] | while read file; do N=$(echo $file | tr -cd '\11\12\40-\176'); mv "$file" "$N"; done
You also might want to change the grep part of this command. Insert all characters you don't want to have.
Be aware the characters are just deleted and not replaced.
If you also want to change names of paths remove the "-type f" option of the find command.
The command may take a long time to execute, you mentioned you have 35k songs. Just be patient. ;)

vectordrake 02-14-2012 07:22 PM

You may also be able to do it with Thunar, the file manager used for xfce (you can use it without xfce), but you may have a lot to rename. I've used it with success for under 100 files.

Have you explored the rename command?

l3ill 02-14-2012 09:17 PM

Since they are music files, are you only concerned about the file names or do you also want to rectify the IDx tags?

If only file names, then the above solutions are good - however, if you're interested in fixing up the tags; I had a similar issue with around 25,000 MP3 files - I used a variety of tag editors on both Windoze and Linux (Ubuntu) clients - and I found an application called "Easy Tag" which did the trick quite well (sudo apt-get install easytag).

It allows the modification of tags (batch entry too - which is useful with lots of files) and also allows renaming - with sub-directories etc, as required. There are a few "smarts" in there too which can help, depending on the situation.

All up, I'd say it's worth a look.

Cheers ... Bill

purevw 02-15-2012 12:39 AM

If you use KDE, you can use krename for a "find and replace". All you would do is to do a search such as *.mp3 in either Konqueror or Dolphin and then select all. Then you can right click and select Action>Rename with Krename. You can set up a rule for each change and then run all rules at once. It offers a preview and also an undo command if something goes wrong.

ununun 02-15-2012 01:55 AM

Quote:

Originally Posted by sys64738
Hi
I've found the following: http://gordonazmo.wordpress.com/2011...from-filename/

I would change it a bit to work on nested folders and to test if it works for you:
Code:

find /path/to/files -type f -print | grep [ÄÖÜäöü߶] | while read file; do N=$(echo $file | tr -cd '\11\12\40-\176'); echo mv "$file" "$N"; done

The output will show the files (filenames) to be changed.
If you are satisfied with the result do:
Code:

find /path/to/files -type f -print | grep [ÄÖÜäöü߶] | while read file; do N=$(echo $file | tr -cd '\11\12\40-\176'); mv "$file" "$N"; done

You also might want to change the grep part of this command. Insert all characters you don't want to have.
Be aware the characters are just deleted and not replaced.
If you also want to change names of paths remove the "-type f" option of the find command.
The command may take a long time to execute, you mentioned you have 35k songs. Just be patient.
__________________
Regards

sys64738

deleting chars is not a problem. thanks just what i needed.


Quote:

Originally Posted by vectordrake

You may also be able to do it with Thunar, the file manager used for xfce (you can use it without xfce), but you may have a lot to rename. I've used it with success for under 100 files.

Have you explored the rename command?

songs are scattered. thunar would not be much help here.

rename, i forgot about it.

thanks

Quote:

Originally Posted by l3ill
Since they are music files, are you only concerned about the file names or do you also want to rectify the IDx tags?

If only file names, then the above solutions are good - however, if you're interested in fixing up the tags; I had a similar issue with around 25,000 MP3 files - I used a variety of tag editors on both Windoze and Linux (Ubuntu) clients - and I found an application called "Easy Tag" which did the trick quite well (sudo apt-get install easytag).

It allows the modification of tags (batch entry too - which is useful with lots of files) and also allows renaming - with sub-directories etc, as required. There are a few "smarts" in there too which can help, depending on the situation.

All up, I'd say it's worth a look.

Cheers ... Bill

i wanna keep keep the tags intact, i dont care about filenames. i dont think easytag would rename dirs.

thanks for the suggestion.

Quote:

Originally Posted by purevw
If you use KDE, you can use krename for a "find and replace". All you would do is to do a search such as *.mp3 in either Konqueror or Dolphin and then select all. Then you can right click and select Action>Rename with Krename. You can set up a rule for each change and then run all rules at once. It offers a preview and also an undo command if something goes wrong.

i use xfce so ... , ok i would try it, if nothing else works.

thanks

ununun 02-15-2012 05:41 AM

Quote:

Originally Posted by sys64738 (Post 4602451)
Hi
I've found the following: http://gordonazmo.wordpress.com/2011...from-filename/

I would change it a bit to work on nested folders and to test if it works for you:
Code:

find /path/to/files -type f -print | grep [ÄÖÜäöü߶] | while read file; do N=$(echo $file | tr -cd '\11\12\40-\176'); echo mv "$file" "$N"; done
The output will show the files (filenames) to be changed.
If you are satisfied with the result do:
Code:

find /path/to/files -type f -print | grep [ÄÖÜäöü߶] | while read file; do N=$(echo $file | tr -cd '\11\12\40-\176'); mv "$file" "$N"; done
You also might want to change the grep part of this command. Insert all characters you don't want to have.
Be aware the characters are just deleted and not replaced.
If you also want to change names of paths remove the "-type f" option of the find command.
The command may take a long time to execute, you mentioned you have 35k songs. Just be patient. ;)

Code:

find /home/ununun/music/ -type f -print | grep [^[:print:]] | while read file; do N=$(echo $file | tr -cd '[:print:]'); mv "$file" "$N" ; done
mv: cannot move `/home/ununun/music/1/25/2/[2008] Me\327\262\302\263\326\262\302\260 Su\327\262\302\263\326\262\302\260 i\327\262\302\274\327\237\302\277\302\275 Eyrum Vi\327\262\302\263\326\262\302\260 Spilum Endalaust/08. Sigur R\327\262\302\263\326\262\302\263s - Illgresi.mp3' to `/home/manish/music/1/25/2/[2008] Me Su i Eyrum Vi Spilum Endalaust/08. Sigur Rs - Illgresi.mp3': No such file or directory
mv: cannot move `/home/ununun/music/1/25/2/[2008] Me\327\262\302\263\326\262\302\260 Su\327\262\302\263\326\262\302\260 i\327\262\302\274\327\237\302\277\302\275 Eyrum Vi\327\262\302\263\326\262\302\260 Spilum Endalaust/11. Sigur R\327\262\302\263\326\262\302\263s - All Alright.mp3' to `/home/manish/music/1/25/2/[2008] Me Su i Eyrum Vi Spilum Endalaust/11. Sigur Rs - All Alright.mp3': No such file or directory
mv: cannot move `/home/ununun/music/1/25/2/[2008] Me\327\262\302\263\326\262\302\260 Su\327\262\302\263\326\262\302\260 i\327\262\302\274\327\237\302\277\302\275 Eyrum Vi\327\262\302\263\326\262\302\260 Spilum Endalaust/07. Sigur R\327\262\302\263\326\262\302\263s - \327\262\302\263\327\237\302\277\302\275ra B\327\262\302\263\326\262\302\241tur.mp3' to `/home/manish/music/1/25/2/[2008] Me Su i Eyrum Vi Spilum Endalaust/07. Sigur Rs - ra Btur.mp3': No such file or directory
.
.
.

basically a filename is converted into esacape sequence form and mv wont detetect these files.

thanks

ununun 02-15-2012 06:23 AM

i executed this script

https://github.com/bk322/bk-goodies/...filenames.bash

what it did actually is move (mv) files of a directory to same file.

i am staying calm :(

now i have 34k songs.

thanks

sys64738 02-15-2012 05:36 PM

Hi
you have said
Quote:

basically a filename is converted into esacape sequence form and mv wont detetect these files.
I think the problem is you've insufficient rights to "/home/ununun/music/1/25/2/" concerning to read or to
"/home/manish/music/1/25/2/" concerning to write.

sys64738 02-15-2012 05:41 PM

btw use a backup before running such a command.

ununun 02-16-2012 02:45 AM

Quote:

Originally Posted by sys64738 (Post 4603460)
Hi
you have said

I think the problem is you've insufficient rights to "/home/ununun/music/1/25/2/" concerning to read or to
"/home/manish/music/1/25/2/" concerning to write.

Code:

ls -l /home/ununun/music/1/25/2/
total 3944
drwxr-xr-x 4 ununun ununun    4096 Aug 23 12:23 2007 - All of a Sudden I Miss Everyone
drwxr-xr-x 2 ununun ununun    4096 Aug 23 12:23 65daysofstatic - We Were Exploding Anyway (2010)
drwxr-xr-x 3 ununun ununun    4096 Aug 23 12:23 M-THIH_by_CoC_for_mediaboom.org
drwxr-xr-x 2 ununun ununun    4096 Aug 23 12:23 The Six Parts Seven - Casually Smashed to pieces
drwxr-xr-x 2 ununun ununun    4096 Aug 23 12:23 The hawk is howling 2008
-rwxr-xr-x 1 ununun ununun 4007197 Aug 23 12:23 [2008] Me
drwxr-xr-x 2 ununun ununun    4096 Feb 15 17:20 [2008] Me???????? Su???????? i?????????? Eyrum Vi???????? Spilum Endalaust
drwxr-xr-x 2 ununun ununun    4096 Aug 23 12:23 [2009] it doesn't matter


sys64738 02-16-2012 07:37 AM

???

ununun 02-16-2012 08:38 AM

Quote:

Originally Posted by sys64738 (Post 4604054)
???

you said i have insuffecient rights in /home/ununun/music/1/25/2

and i ls -l to show that it is not the case.

sys64738 02-16-2012 11:33 AM

and I guess you are using the id "manish" and have write rights to "/home/manish/music/1/25/2/"?

ununun 02-16-2012 11:52 AM

yes manish == ununun ; just avoiding extra information.

so whats wrong with the script.

ps. i used conmv to convert to utf-8 character set at the time i downloaded these songs.


All times are GMT -5. The time now is 08:19 AM.