LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 02-14-2012, 01:17 PM   #1
ununun
Member
 
Registered: Jun 2011
Posts: 82

Rep: Reputation: Disabled
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
 
Old 02-14-2012, 06:00 PM   #2
sys64738
Member
 
Registered: May 2008
Location: NRW/Germany
Posts: 105

Rep: Reputation: 30
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.
 
Old 02-14-2012, 08:22 PM   #3
vectordrake
Senior Member
 
Registered: Nov 2003
Location: NB,Canada
Distribution: Something alpha or beta, binary or source...
Posts: 2,280
Blog Entries: 4

Rep: Reputation: 47
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?
 
Old 02-14-2012, 10:17 PM   #4
l3ill
LQ Newbie
 
Registered: Apr 2010
Posts: 1

Rep: Reputation: 0
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
 
Old 02-15-2012, 01:39 AM   #5
purevw
Member
 
Registered: Jan 2007
Location: Texas
Distribution: OpenSuSE 13, Kernel 3.13.3
Posts: 90

Rep: Reputation: 45
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.
 
Old 02-15-2012, 02:55 AM   #6
ununun
Member
 
Registered: Jun 2011
Posts: 82

Original Poster
Rep: Reputation: Disabled
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
 
Old 02-15-2012, 06:41 AM   #7
ununun
Member
 
Registered: Jun 2011
Posts: 82

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by sys64738 View Post
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
 
Old 02-15-2012, 07:23 AM   #8
ununun
Member
 
Registered: Jun 2011
Posts: 82

Original Poster
Rep: Reputation: Disabled
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
 
Old 02-15-2012, 06:36 PM   #9
sys64738
Member
 
Registered: May 2008
Location: NRW/Germany
Posts: 105

Rep: Reputation: 30
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.

Last edited by sys64738; 02-15-2012 at 06:39 PM. Reason: missing word
 
Old 02-15-2012, 06:41 PM   #10
sys64738
Member
 
Registered: May 2008
Location: NRW/Germany
Posts: 105

Rep: Reputation: 30
btw use a backup before running such a command.
 
1 members found this post helpful.
Old 02-16-2012, 03:45 AM   #11
ununun
Member
 
Registered: Jun 2011
Posts: 82

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by sys64738 View Post
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
 
Old 02-16-2012, 08:37 AM   #12
sys64738
Member
 
Registered: May 2008
Location: NRW/Germany
Posts: 105

Rep: Reputation: 30
???
 
Old 02-16-2012, 09:38 AM   #13
ununun
Member
 
Registered: Jun 2011
Posts: 82

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by sys64738 View Post
???
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.
 
Old 02-16-2012, 12:33 PM   #14
sys64738
Member
 
Registered: May 2008
Location: NRW/Germany
Posts: 105

Rep: Reputation: 30
and I guess you are using the id "manish" and have write rights to "/home/manish/music/1/25/2/"?
 
Old 02-16-2012, 12:52 PM   #15
ununun
Member
 
Registered: Jun 2011
Posts: 82

Original Poster
Rep: Reputation: Disabled
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Recommendations for English songs, with touching/jolly lyrics TheIndependentAquarius General 52 09-13-2011 11:22 AM
rename a directory filename with " \ " character d4v3 Linux - Newbie 8 06-07-2011 07:45 PM
LXer: Bash massive rename to solve feh problem LXer Syndicated Linux News 0 02-13-2010 02:12 AM
Convert static library (Filename.a) to dynamic shared object (filename.so) afx2029 Linux - Software 4 08-17-2007 07:07 AM
linux shell - extract filename from and song info from text database d003 Programming 1 07-23-2003 05:06 AM


All times are GMT -5. The time now is 01:55 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration