GitXplorerGitXplorer
M

MetaDataMover

public
31 stars
6 forks
1 issues

Commits

List of commits on branch master.
Unverified
8accc2141300ac250da29b2f47a333a1e4ca6106

removed header

MMortimerp9 committed 13 years ago
Unverified
1277ca3b5b4ad8285b1c866897397154a6ea3ba5

better readme

MMortimerp9 committed 13 years ago
Unverified
b5bf9dcd57b86b3cbb2a20fb989a9f6da551848e

missing bits

MMortimerp9 committed 13 years ago
Unverified
532dfad398febcc1cf567f6905e5851d7e55e671

new automatic way of building the DMG package.

MMortimerp9 committed 17 years ago
Unverified
b7cd0d760692fc2fd3c7a6fdba54b4e156b4771e

*added a icns file for using when building the dist package*- is now allowed in path pattern and tag values* blank spaces around tag values are trimmed* / are replaced by _ in tag values* use file modification date when nothing else is availlable* only one exiftool object is created, and static code is now out of the loop. Need to test if that helps with BIG directories

MMortimerp9 committed 17 years ago
Unverified
d4d04b3413c40838f4dd242818fd70ef7c037a08

review of the README file

MMortimerp9 committed 17 years ago

README

The README file for this repository.

Principle

This is an action for Mac OS X Automator that takes a special path pattern and will try to rename the files it get in inputs according to that pattern.

We call it a "path pattern" because it can contain elements that will be replaced for each file with information coming for the meta data stored in the file.

Example of moving photos

Let's make an example. The script supports the EXIF meta data field included in photo files by your camera. It can therefore use them to move the images.

Example Results

Let's say you have a bunch of images that you would want to move in directories named from the date they were taken at, like:

2007
   08
     12
       IMG_1.jpg
       IMG_2.jpg
   07
     25
       IMG_3.jpg
2006
    01
      28
       IMG_4.jpg

You can set the path pattern parameter of the Automator action with the pattern: %Y/%m/%d/

The action will extract information from the EXIF data and replace the special markers in the pattern:

  • %Y will be replaced by the year
  • %m will be replaced by the month
  • %d will be replaced by the day

the directory structure will be created and the file moved in the right directory.

There is more detail later on how the patterns work, but this is the basic idea.

Installation

Download and open the following disk image.

Check out the license and move the MetaDataMove.action file in the directory ~/Library/Automator/ (for a particular user) or /Library/Automator/ (for all users)

Extract the archive and inside you will find MetaDataMover.action, move this file in the directory ~/Library/Automator/ (for a particular user) or /Library/Automator/ (for all users)

Using the Action

Once installed, you will find the action in Automator under the Finder application. Just drag and drop it in the workflow just after an action that returns a list of files.

The action will return a list of the moved/renamed files.

Here are the option:

MetaDataMover screenshot

1- do you wish to copy or move the files, default is copy, 2- what path pattern should be used. This is the pattern for the moving/renaming of the file. The default is for EXIF patterns: %Y/%m/%d/, 3- in which root directory to put the new files. The path pattern will be applied from that directory. The default is the directory where the current file is, 4- you can check this option and follow the action by the "View Results" action from Automator to do a test run, 5- you can check this option if you are OK with the action overwriting existing file. The default is to not overwrite existing files, see clash.

Special Patterns Elements

Most of the pattern -- except for the date notation in the EXIF case -- elements follow a simple notation, they are the name of a field in the file metadata with columns (':') around. You can use more than once the same marker in the pattern if you wish.

The available meta data fields change according to the file type you are passing to the action. The main fields for photos, music files and PDF are discussed later. Generally, the action uses ExifTool by Phil Harvey and therefore, the fields read by this tool can be used, for more details, please see ExifTool tag names documentation.

The action also offers some basic pattern elements:

  • :basename: is the name of the file, without extensions,
  • :ext: is the extension of the file, with the period (.),
  • :cnt: will be replaced by the clash avoidance (see clash) counter if a file with the same name already exists, otherwise, it will just be removed.

Detailed Behaviour

Here are the specifics on how the action deals with the different possible cases.

Trailing Slash

If the path pattern finishes with a /, then it is taken as the directory where the file should be moved, without being renamed.

File Renaming

If the path pattern doesn't finish with a /, the last part of the path is supposed to be the renaming pattern for the file. If it doesn't contain an extension (. followed by something), then the extension of the original file will be used.

File Clash avoiding

If the option overwrite is not checked, the action will avoid replacing an existing file with a file it is renaming. The action has two choices then:

  • if the path pattern you specified uses the :cnt: special marker, it will replace this by a counter.
  • otherwise, the action will add a counter at the end of the file name, just before the file extension. The action will start with the counter at 1 and try to write the file, if a file with the same counter already exist, it will increment the counter until it finds a new file name.

Introduction to Photo meta data

 

EXIF Date Patterns

The photo files containing EXIF metadata can use another special notation to extract the date when the photo was taken (as described in the previous example). The date pattern format is the one provided by the strftime tool. Check out its man page for details. Here are useful fields:

Useful time/date formating
Pattern Meaning
%d The day of the month as a decimal number (range 01 to 31).
%H The hour as a decimal number using a 24-hour clock (range 00 to 23).
%I The hour as a decimal number using a 12-hour clock (range 01 to 12).
%S seconds
%m The month as a decimal number (range 01 to 12).
%M The minute as a decimal number (range 00 to 59).
%s The number of seconds since the Epoch, i.e., since 1970-01-01 00:00:00 UTC.
%u The day of the week as a decimal, range 1 to 7, Monday being 1.
%y The year as a decimal number without a century (range 00 to 99).
%Y The year as a decimal number including the century.

EXIF Patterns Elements

You can also tell the tool to extract other EXIF information by putting the EXIF field name between columns (:) in the pattern. For example, %Y/%m/%d/:Model:/ will put the photos in subdirectories by date and then by model of camera.

Useful EXIF fields
Field Meaning
:Model: the name of the camera model
:Manufacturer: the camera brand
:ISO: the iso setting
:FNumber: the aperture in f value

Introduction to Music files meta data

Most of the modern music file formats like mp3 support meta data fields to store the name of the track, the performing artist, etc... The action can extract these fields and can be used to organise a music collection automatically.

Useful ID3 fields
Field Meaning
:Artist: the performing artist
:Album: the album of this track
:Title: the title of this track
:Genre: the genre classification of this track

Organising PDF Documents

You can also use the automator action to organise your pdf documents if they contain the right metadata. If the author of the file has tagged it with the right information, you can extract his name, etc... etc...

Useful PDF fields
Field Meaning
:Title: the document title
:Creator: the document creator
:Author: the document author

Other file formats supported

This automator action is based on the great ExifTool library. It will support all metadata format supported by that library. For details on each format and the tags availlable for that format, see the exiftool tag names documentation page or go directly to the format you are interested in from this list:


Localisation

The script is already localised in French, Italian and English. If you want to propose a new localisation, contact me.


Credits

This code uses ExifTool by Phil Harvey for all the metadata extraction: http://www.sno.phy.queensu.ca/~phil/exiftool/


License

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.