Main Menu

Using Exiftool on Ubuntu

Started by Pedro_pt, December 07, 2011, 01:59:36 PM

Previous topic - Next topic

Pedro_pt

Before I get started  i will briefly introduce myself: I am a student from Portugal and I am starting graduating informatic engineering, and my English is not the best as you can see. XD I will try to clarify the best as I can.

Now I have to make a project in which I have to extract information from music and video files from a directory using ExifTool. Then while using Haskell programming language i will have to transfer the files data  to a catalog. Our teachers provided a "beginning code" and now we have to change it to complete the project.

Now I will show what i have done so far:
I am trying to select only the audio files from the directory to make the first part of the catalog:

exiftool -args -r -if '$mimetype eq "audio/mpeg"' * >> songs.txt

I want to be more specific like selecting all the files whose mimetype is audio* but by some reason the code with the wildcard on -if expression doesn't work.

On Haskell we have to make a list of the data which I will work on later, but the problem is right now on the beginning XD

mymain =
do {
      system "exiftool -args -r -if '$mimetype eq "audio"' * >> songs.txt" ;
      a <- readFile "songs.txt" ;
      let text = map words (lines a)
      in print text

    }

This is still very primitive, now I just  want to extract the files data on which i will work later with the lists. The problem here is that the Haskell separates the system line because of the "" and gives the error it can't understand what is audio:

mymain =
do { system "exiftool -args -r -if '$mimetype eq
audio
  '* >> songs.txt


I think i can't use the "" in the expression, so i have to try something else without it but i can't figure out!
I know this is VERY DUMMY but i am still starting programming. If you didn't understand anything i will try to explain better.
Thank you for your advice!

Phil Harvey

Quote from: Pedro_pt on December 07, 2011, 01:59:36 PM
I am trying to select only the audio files from the directory to make the first part of the catalog:

exiftool -args -r -if '$mimetype eq "audio/mpeg"' * >> songs.txt

I want to be more specific like selecting all the files whose mimetype is audio* but by some reason the code with the wildcard on -if expression doesn't work.

Try this: exiftool -args -r -if '$mimetype =~ /^audio/' * >> songs.txt

Google for "perl regular expressions" to learn more about this.

QuoteI think i can't use the "" in the expression, so i have to try something else without it but i can't figure out!

Conicidentally, my command above solves this problem, but all you need to do is figure out how to escape a quote in Haskell to use a quote in the command.  In many languages you do this by putting a backslash (\) before the quote.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Pedro_pt