Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Access Special Info in files, like photos, audio, video

I am trying to automate the sorting of files using shell scripting.

I want to file different things in different places based on things like:


- what camera they were taken from

- what resolution the picture is

- perhaps GPS location

- for mp3's maybe audio compression or codec

- for audio files, are the podcasts, from an iPhone, voice recorder.


For example I dump files into a directory and want a cron job to take

any .jpg files and figure out where they came from? Were they downloaded

from the Internet, saved from email, taken from a camera or phone, if so

what device.


I know there is data somewhere in these files, and that finder, preview

and other programs can find it and get at it, but is there a way to do it

on my own?


I have heard of resource forks but I really have no idea what they are or

how to access them. If I could figure that out, or even where the data

might be inside the file and I could pull it out with shell commands, but

where is any of this data documented?


Just a pointer for jpg's, mp3's. mov's, mp4's would be a great start.

iMac, OS X Yosemite (10.10.3), 24",120G SSD,6GRAM,2T home,4T TM

Posted on Jan 15, 2016 12:52 AM

Reply
3 replies

Jan 15, 2016 7:06 AM in response to bruxxx

Metadata is stored in multiple file forks or streams (data forks, extended attributes, resource forks) on HFS+. These days, resource forks are rarely used. Apple supplies command line metadata readers- xattr and mdls but these tools lack some of the functionality that you are looking for. I recommend using Phil Harvey's exiftool in conjunction with the Apple supplied tools.

Jan 15, 2016 12:40 PM in response to Mark Jalbert

Thanks Mark. I will check it out.


In wikipedia they mention this:

From the POSIX interface, the resource fork could be accessed as

filename/..namedfork/rsrc
or as
filename/rsrc
; the shorter form was deprecated in OS X 10.4 and removed completely in Mac OS X 10.7

I did not really get far with that other than they actually do show up under the ls command.

I'm trying to find a way to do this programmatically in a script.

I guess there are two parts to this:

1. what kind of files have what kind of data

2. how to access and retrieve the data associated with a given file type.

Access Special Info in files, like photos, audio, video

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.