How to find untagged audio files?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to find untagged audio files?
# 29  
Old 12-22-2010
Thanks for the explanation.
Quote:
Quote:
Is 'f || f++' just a complex way to say 'f=1'?
No, it's a simple way to say f++ if f = 0 or unset Smilie
So it's just a complex way to say 'f=1-f'. Smilie
Or if it's possible in awk: even shorter f=!f

Quote:
Because every time we're working on the previously saved data,
therefore the last one should be processed after the entire input is read.
Aha, but why not just process the current data?
# 30  
Old 12-22-2010
Quote:
Originally Posted by MrZehl
Thanks for the explanation.

So it's just a complex way to say 'f=1-f'. Smilie
No, if f = 1 f = 1 - f sets f to 0, f || f++ sets it to 1 Smilie

Quote:
Aha, but why not just process the current data?
Because we don't know where the logical record ends,
we know only where it begins (for mp3s we could use the empty line as a record separator, but not for flacs, this code handles both types).

---------- Post updated at 02:33 PM ---------- Previous update was at 02:32 PM ----------

Quote:
Originally Posted by MrZehl
Thanks for the explanation.
So it's just a complex way to say 'f=1-f'. Smilie
Or if it's possible in awk: even shorter f=!f
[...]
No, what I mean could be shortened in Perl Smilie

Code:
$f ||= 1

# 31  
Old 12-22-2010
Hmm isn't it possible to include echo 'start' and echo 'end' in the exec part of find? If you can process the current data, the part after 'END' can be removed.

Maybe even something like echo 'start %filename'; id3 -Rl .. ;echo 'end %filename'. That would make more flexible too, because it makes it possible to to add other formats which maybe have no option to output the filename itself.

Yes, you heard it.. other formats. Smilie
I'll gonna play with this code and try to make support it even more formats.
# 32  
Old 12-22-2010
Quote:
Originally Posted by MrZehl
Hmm isn't it possible to include echo 'start' and echo 'end' in the exec part of find? If you can process the current data, the part after 'END' can be removed.

Maybe even something like echo 'start %filename'; id3 -Rl .. ;echo 'end %filename'. That would make more flexible too, because it makes it possible to to add other formats which maybe have no option to output the filename itself.
This is not possible with the current implementation, because for performance reason I'm passing 1000 or more filenames at a time to id3 and metaflac.
So you'll end up with:

Code:
start
filaname1 filename2 [.. filenamen]
end

And then we process all the data with a single awk invocation.
It could be easily modified in order to process one file at a time,
but the performance will be very different.

But why the END block bothers you in the first place? Smilie

Quote:
Yes, you heard it.. other formats. Smilie
I'll gonna play with this code and try to make support it even more formats.
Great Smilie

Last edited by radoulov; 12-22-2010 at 10:33 AM..
# 33  
Old 12-22-2010
Quote:
Originally Posted by radoulov
This is not possible with the current implementation, because for performance reason I'm passing 1000 or more filenames at a time to id3 and metaflac.

It could be easily modified in order to process one file at a time,
but the performance will be very different.

But why the END block bothers you in the first place? Smilie
In the latest version there is only an extra function call, so it's no big deal anymore. Before that it was a lot of extra code. I don't know yet if that will be a problem with the other formats yet. If filenames can be included in the output there should be no problem.
Only I like to have things clear, so I prefer to process current data instead of processing data of the file before this. Just seems neater. And prevents bugs. The wrongly reported mp3 file was because of this. But now it works so it's okay.

But I just need to understand the find part.
Code:
find . -type f -name '*.[Mm][Pp]3' -exec id3 -Rl {} + -o \
  -name '*.[Ff][Ll][Aa][Cc]' -exec metaflac --show-md5sum  \
    --with-filename --export-tags-to=- {} +

What makes that you send all files in one go? I thought the exec command did always all files one by one. Appearently I'm mistaken here. Please enlighten me.

How should this line look like if the files are sent one by one?
And if added echo start and echo end, how should that look like? Maybe I don't need it know, but I'll like to understand this.

Last edited by MrZehl; 12-22-2010 at 10:59 AM.. Reason: typo
# 34  
Old 12-22-2010
Quote:
Only I like to have things clear, so I prefer to process current data instead of processing data of the file before this.
Just seems neater. And prevents bugs.
I agree, make it clear and avoiding bugs are valid reasons.
The only problem is that often you could just not afford it,
because of the input format.

Quote:
What makes that you send all files in one go? I thought the exec command did always all files one by one.
I'm using a particular syntax. This one process the files one by one:

Code:
find -name '*.mp3' -exec sh -c '
  echo start 
  echo "$0" 
  echo end
  ' {} \;

This passes n at a time (note the + at the end):

Code:
find -name '*.mp3' -exec sh -c '
  echo start 
  echo "$@"
  echo end
  ' {} +

# 35  
Old 12-23-2010
Thanks. It seemed I needed that for ogg files. I added support for ogg and it works.
I renamed the mp3 and flac variables to id3 and vorbis, which are the names of the tag format. And I messed up the output the get it on one line which makes it easier to count the list. It's more compact now. Sorry for that. Smilie

Code:
find . -type f -name '*.[Mm][Pp]3' -exec id3 -Rl {} + -o \
               -name '*.[Ff][Ll][Aa][Cc]' -exec metaflac --show-md5sum \
                  --with-filename --export-tags-to=- {} + -o \
               -name '*.[Oo][Gg][Gg]' -exec sh -c 'echo "$0";vorbiscomment -lRe "$0"' {} \; |
  awk 'BEGIN {
    id3n        = split("album artist title track",       id3_tags)
    vorbisn     = split("album artist title tracknumber", vorbis_tags)
    vorbisfile  = "\\.([Ff][Ll][Aa][Cc]|[Oo][Gg][Gg])$"    
    ignorepatt  = "^ *(unknown|track *[0-9]*)* *$"    
    }
  
  /^Filename/ || $1 ~ vorbisfile {
    fn && check_tags(fn ~ vorbisfile ? "vorbis" : x)
    fn = /^Filename/ ? $2 : $1; f = x        
     }
  
  { 
    if (split($0, tmp, "=") == 2) { $1 = tmp[1]; $2 = tmp[2] }
    tags[tolower($1)] = $2 
      }
  
  END { check_tags(fn ~ vorbisfile ? "vorbis" : x) 
      printf "\n"
      }
  
  func check_tags(ty,   f) {
    if (ty == "vorbis") {
      for (i = 1; i <= vorbisn; i++) {
        if (tolower(tags[vorbis_tags[i]]) ~ ignorepatt) {
          invalid_tags[vorbis_tags[i]] = tags[vorbis_tags[i]]; f || f++ 
          }
        }
      }    
    else {
      for (i = 1; i <= id3n; i++) {
        if (tolower(tags[id3_tags[i]]) ~ ignorepatt) {
          invalid_tags[id3_tags[i]] = tags[id3_tags[i]]; f || f++
          }
        }
      }  
    if (f) {
      printf "%s%s *** missing/invalid tags: ", RS, fn
        for (t in invalid_tags)
          printf "[%s=\"%s\"]", t, invalid_tags[t]
      printf " ***"  
      }    
    split(x, tags); split(x, invalid_tags)   
    }' FS=:

To squeeze it a little more.. would something like this be possible?

Code:
func check_tags(ty,   f, number, tagarray) {
   for (i = 1; i <= number; i++) {
      if (tolower(tags[tagarray[i]]) ~ ignorepatt) {
        invalid_tags[tagarray[i]] = tags[tagarray[i]]; f || f++ 
      }
    if (f) {
      printf "%s%s *** missing/invalid tags: ", RS, fn
        for (t in invalid_tags)
          printf "[%s=\"%s\"]", t, invalid_tags[t]
      printf " ***"  
      }    
    split(x, tags); split(x, invalid_tags)   
    }

Oh.. I found 16000 invalid audio files. I guess I'll need a script that can fill most of them automaticly. Smilie
This User Gave Thanks to MrZehl For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need a script for automation the convert a lot number audio files to another format

I have a lot number audio files in the MP3 proprietary format, I want to convert them to 'opus' the free and higher quality format, with keep metadata also. My selection command-line programs are SoX (Sound eXchange) for convert MP3 files to 'AIFF' format in order to keep quality and metadata*... (1 Reply)
Discussion started by: temp-usr
1 Replies

2. UNIX for Dummies Questions & Answers

Remove untagged and junk data from an XML

Hi All , I have seen a lot of code samples which suggest how to remove the junk data from and XML , I need a code in unix which removes the junk characters as well as the valid characters those are not in XML tags , for example my XML is as follows : <?xml version="1.0"... (6 Replies)
Discussion started by: IshuGupta
6 Replies

3. Slackware

Problems with audio recording in Audacity 2.0.5. Slackware64 14.1; Intel HD Audio.

I'm trying to record audio using Audacity 2.0.5 installed from SlackBuilds. My system is 64-bit Slackware 14.1 and a sound card is Intel HD Audio. I didn't change my sound system to OSS. (Default sound system in Slackware 14.1 is ALSA, isn't it?) First, I set Internal Microphone slider in KMix... (2 Replies)
Discussion started by: qzxcvbnm
2 Replies

4. Shell Programming and Scripting

Manipulating audio files server side

Hi All, I have next to zero knowledge on what I am about to ask so I will just ask it in plain English :) I am wondering how best to go about manipulating audio files server side. The manipulations required are join files one after the other, eg, audio1 + audio2 + audio3 + audio4 = audio5 ... (0 Replies)
Discussion started by: linuxgoat
0 Replies

5. Shell Programming and Scripting

Script to list files not present in audio.txt file

I am having following folder structure. /root/audios/pop /root/audios/jazz /root/audios/rock Inside those pop, jazz, rock folders there are following files, p1.ul, p2.ul, p3.ul, j1.ul, j2.ul, j3.ul, r1.ul, r2.ul, r3.ul And I have a file named as "audio.txt" in the path /root/audios,... (11 Replies)
Discussion started by: gopikrish81
11 Replies

6. UNIX for Dummies Questions & Answers

Find Audio Files With Specific Bandwidth?

Hi, I would like to write a shell script that will: -search the files of a specific user to find any audio files with a bandwidth iqual or greater than 192 kps - on the results i should see the file name along with all the whole file route and each file's size So I guess i should be using... (1 Reply)
Discussion started by: ubu-user
1 Replies

7. Programming

Playing Audio files in C

Hi All, Looking for an assistance on how to access the speakers of my machine and play audio files using C. Any tutorials will be of great help. Regards, Sayantan. (1 Reply)
Discussion started by: Sayantan
1 Replies
Login or Register to Ask a Question