LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-17-2019, 03:07 PM   #1
Stanton02
LQ Newbie
 
Registered: Dec 2019
Posts: 1

Rep: Reputation: Disabled
id3v2 script problem


Hi guys! i'm here with this simple script:
Code:
#!/bin/bash

for i in {1..9}
do
	
	title_mp3=$( ls *0$i* )
	echo "$title_mp3"
	title_mp3=$(ls 0$i* |sed 's/ /\\ /g'|sed "s/'/\\\'/g")
	id3v2 -t 0"$i".mp3 "$title_mp3"
done

for i in {10..39}
do
	
	title_mp3=$( ls *$i* )
	echo $title_mp3
done
i wrote this script in order to rename the title tag of mp3 chapter files of an audiobook.
These files have names like:
01 La regola dell'equilibrio_Uno.mp3
...
39 La regola dell'equilibrio_Trentuno.mp3
With the above script i want to assign the title 0$i_$title_mp3.mp3 to alle files up to the 9th and the title $i_$title_mp3.mp3 to all the other files which start with 2 numbers (like 10, 11, 12 and so on).

So the question that i want to present are exentially two:
1 - I have a problem with the id3v2 command that regardless the "$title_mp3" variable is correct, during execution of the script i obtain the following result:

Couldn't stat file '01\ La\ regola\ dell\'equilibrio_Uno.mp3'

2 - you maybe think that this script is improvable? if yes how?

thank you so much for your TIME!
 
Old 12-17-2019, 06:50 PM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
I don't know why id3v2 complains, but you don't have to treat single digits and double digits separately. Just do
Code:
for i in {01..39}
...
EDIT: Perhaps id3v2 doesn't see the MP3 file because the name is not quite correct. Double-check with stat "$i.mp3" or if [ -f "$i.mp3" ]; then echo exists; fi.

Last edited by berndbausch; 12-17-2019 at 06:56 PM.
 
Old 12-18-2019, 01:27 AM   #3
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
...and don't parse ls ...
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] using id3v2 to tag mp3 files - script problem nickfromnz Linux - Software 4 01-07-2012 07:55 PM
ID3v1 and ID3v2 tags = ? newbiesforever Linux - General 2 08-21-2008 12:51 AM
compiling grip with id3lib for id3v2 support xBillyGoatx Linux - Software 1 12-02-2006 06:34 PM
Looking for the ultimate CLI id3v2 editor javeree Linux - Software 0 10-17-2005 06:21 AM
Lost in the id3v2 tagger/renamer wilderness slakmagik Linux - Software 3 11-30-2003 07:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:57 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration