Author Topic: Using Exiftool on Ubuntu  (Read 3400 times)

Pedro_pt

  • Newbie
  • *
  • Posts: 2
Using Exiftool on Ubuntu
« on: December 07, 2011, 01:59:36 PM »
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

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14405
    • ExifTool Home Page
Re: Using Exiftool on Ubuntu
« Reply #1 on: December 07, 2011, 02:13:15 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.

Quote
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!

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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Pedro_pt

  • Newbie
  • *
  • Posts: 2
Re: Using Exiftool on Ubuntu
« Reply #2 on: December 07, 2011, 02:21:10 PM »
Thank you very much Mr. Phil!