You are not logged in.
Pages: 1
Hi,
I've got tons of MP3 files with ISO8859-8 id3 tags. I want to convert them all to Unicode.
I've made a list of all the MP3 files in a file called "templist".
I've converted all spaces " " to "\ " in the file using sed, and added " at the end and the begining of every line.
The program mp3unicode is used to convert id3 tags. The program's syntax is:
mp3unicde <myoptions> file1 file2 file3 ...
How do I "cat" the "templist" file at the end of the mp3unicode command?
None of these worked:
cat templist | mp3unicde <..>
or
mp3unicde <..> `cat templist`
Thanks a lot,
fiod
Offline
mp3unicde <myoptions> $(cat templist) should work, but so should the backticks version. What error did you get with backticks?
Another option if you're in a hurry is to just put mp3unicde <myoptions> at the front of your list of files, replace all newlines with spaces, and then execute the file with sh <filename>
Or you could echo the lines in a for loop and run mp3unicde for each one.
Last edited by Dusty (2009-02-03 21:16:45)
Offline
Not sure what the problem is, but a simple loop like this should work:
#!/bin/sh
for i in `cat templist`; do
mp3unicde [options] "$i"
done
If you do it this way then you don't have to do any fancy thing to the templist file -- no quotes necessary and you don't need to do anything special about the spaces, etc.
Offline
Hi,
Thanks a lot for the replies.
I'll check the solutions.
Thanks again,
fiod
Offline
Not sure what the problem is, but a simple loop like this should work:
#!/bin/sh for i in `cat templist`; do mp3unicde [options] "$i" done
If you do it this way then you don't have to do any fancy thing to the templist file -- no quotes necessary and you don't need to do anything special about the spaces, etc.
The filenames contain spaces, thus this solution doesn't work.
Can you think of how to change this, so that the "$i" will contain the entire file name every iteration?
Thanks
fiod
Offline
fwojciec wrote:Not sure what the problem is, but a simple loop like this should work:
#!/bin/sh for i in `cat templist`; do mp3unicde [options] "$i" done
If you do it this way then you don't have to do any fancy thing to the templist file -- no quotes necessary and you don't need to do anything special about the spaces, etc.
The filenames contain spaces, thus this solution doesn't work.
Can you think of how to change this, so that the "$i" will contain the entire file name every iteration?
Thanks
fiod
The spaces are not going to be a problem, since $i variable is contained inside quotes.
The loop will basically take a line at the time from the templist file and give it as an argument to mp3unicde tool -- it will iterate like this through the entire templist file.
Last edited by fwojciec (2009-02-03 21:37:19)
Offline
fiod wrote:fwojciec wrote:Not sure what the problem is, but a simple loop like this should work:
#!/bin/sh for i in `cat templist`; do mp3unicde [options] "$i" done
If you do it this way then you don't have to do any fancy thing to the templist file -- no quotes necessary and you don't need to do anything special about the spaces, etc.
The filenames contain spaces, thus this solution doesn't work.
Can you think of how to change this, so that the "$i" will contain the entire file name every iteration?
Thanks
fiodThe spaces are not going to be a problem, since $i variable is contained inside quotes.
The loop will basically take a line at the time from the templist file and give it as an argument to mp3unicde tool -- it will iterate like this through the entire templist file.
Thanks for the reply.
Example:
This is the text file:
aa bb
cc dd
ee ff
This is the script:
#!/bin/sh
for i in `cat done`; do
#mp3unicode -s iso8859-8 -2 unicode "$i"
echo "$i"
done
This is the output:
[fio@lgtux /tmp/example]$ ./sc
aa
bb
cc
dd
ee
ff
[fio@lgtux /tmp/example]$
This means that the "$i" doesn't work as expected. right?
Thanks again,
fiod
Offline
You're right.
The loop should look like this:
#!/bin/sh
for i in "`cat templist`"; do
mp3unicde [options] "$i"
done
EDIT: Or this:
#!/bin/sh
cat templist | while read N
do
mp3unicde [options] "$N"
done
Last edited by fwojciec (2009-02-03 22:01:08)
Offline
You're right.
The loop should look like this:#!/bin/sh for i in "`cat templist`"; do mp3unicde [options] "$i" done
EDIT: Or this:
#!/bin/sh cat templist | while read N do mp3unicde [options] "$N" done
Hey,
Thanks a lot for all the help.
Still no luck:
When typing:
mp3unicode -s iso8859-8 "./Cranberries/The Cranberries - Analyse - 01 Linger (live).mp3"
everything works great.
The file t2 is:
"./Cranberries/The Cranberries - Analyse - 01 Linger (live).mp3"
"./Cranberries/The Cranberries - No Need to Argue - 01 Ode to My Family.mp3"
and when issuing the script, which is:
#!/bin/sh
for i in "`cat t2`"; do
mp3unicode -s iso8859-8 -2 unicode "$i"
# echo "$i"
done
i get:
[fio@lgtux /tmp/ex2]$ ./sc
Error: Cannot open file: "./Cranberries/The Cranberries - Analyse - 01 Linger (live).mp3"
"./Cranberries/The Cranberries - No Need to Argue - 01 Ode to My Family.mp3".
[fio@lgtux /tmp/ex2]$
Any suggestions?
Thanks
fiod
Offline
Maybe the quotes in the t2 file are causing the problems -- they shouldn't be needed in either case...
Also, since the files specified in t2 file start with ./* you have to make sure that you are in the correct directory. You can add "cd /directory/with/music/files" at the beginning of the script, before the loop.
Offline
Maybe the quotes in the t2 file are causing the problems -- they shouldn't be needed in either case...
Also, since the files specified in t2 file start with ./* you have to make sure that you are in the correct directory. You can add "cd /directory/with/music/files" at the beginning of the script, before the loop.
Checked both..
I've tried the script without "" in the t2 file, and made sure that I am in the corrent directory.
Still no luck...
Offline
Strange.
Maybe an alternative approach is required. What about using find? Something like this:
#!/bin/sh
find /path/to/music/files -type f -name *.mp3 | while read N
do
mp3unicde [options] "$N"
done
Careful, because this will also recurse into directories within the specified directory.
Offline
Strange.
Maybe an alternative approach is required. What about using find? Something like this:
#!/bin/sh find /path/to/music/files -type f -name *.mp3 | while read N do mp3unicde [options] "$N" done
Careful, because this will also recurse into directories within the specified directory.
Worked like a charm.
I wonder why the previous version did not work.
Thanks a lot!
fiod
Offline
I'm glad it worked
Offline
Pages: 1