A Batch File For Facebook

Started by LacOniC, November 29, 2011, 05:59:40 AM

Previous topic - Next topic

LacOniC

Facebook can read Copyright info from EXIF and set it to Description under photo automatically for a while. So i want to fill Copyright info with Exiftool. My file is like that:

exiftool "-FileName<DateTimeOriginal" -d "%%y%%m%%d%%H%%M%%S%%%%-c.%%%%e" ESKI
exiftool -overwrite_original "-Copyright<DateTimeOriginal" -d "%%d.%%m.%%y %%H:%%M" ESKI
exiftool "-Directory=YENI" ESKI

I can set DateTimeOriginal into Copyright like: 31.01.11 11:11

But i want some extra info near date like ISO. How can i add these to Copyright after DateTimeOriginal like "31.01.11 11:11 1600"?

Btw, do you advice anything to improve performance in my batch file?

Thanks in advance.

Phil Harvey

Quote from: LacOniC on November 29, 2011, 05:59:40 AM
But i want some extra info near date like ISO. How can i add these to Copyright after DateTimeOriginal like "31.01.11 11:11 1600"?

exiftool "-Copyright<$DateTimeOriginal $ISO" ...

QuoteBtw, do you advice anything to improve performance in my batch file?

You can combine the last 2 commands by setting the directory and copyright in the same command.  Unfortunately this can't be easily combined with the first command because you are using two different date formats.  But if you are serious about performance you could create a user-defined tag to generate a reformatted date to allow all of this to be done in a single command.  Your speed should be 2 to 3 times faster if you can combine these all into one command.

- 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 ($).

LacOniC

Can i add new filename to copyright also, like DateTimeOriginal Filename

I can add as Filename with extension but $f does not work. =S

Btw, thank you very much Phil. For answer(s) and this great work.

Phil Harvey

There is a user-defined Composite tag called "BaseName" in the sample config file included with the full exiftool distribution.  This gives you the file name without the extension, just for purposes like this.  With this installed, you add "$basename" to the format string to get what you want.

- 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 ($).

LacOniC

Hey Phil. I migrated to mac from windows. Now i am trying add this command (as service) to automator but nothing happens. For example that works well for me in terminal:

exiftool '-FileName<DateTimeOriginal' -d %y%m%d%H%M%S%%-c.%%le MyPhotoFolder

I try that in automator:

for f in "$@"
do
exiftool '-FileName<DateTimeOriginal' -d %y%m%d%H%M%S%%-c.%%le "$f"
done

Nothing happens. How can i run first one in automator in a folder?

Phil Harvey

I'm sorry, I have never used the automator.  Perhaps this is better asked in an automator forum.

- 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 ($).

LacOniC

Thanks anyway.

Btw i am using Exiftool for 4 years as u can see in my previous message and i want to say:

THANK YOU VERY MUCH for this great tool and your interest! You are a hero! =)

Phil Harvey

...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 ($).

Hayo Baan

Quote from: LacOniC on March 13, 2015, 08:47:10 AM
Hey Phil. I migrated to mac from windows. Now i am trying add this command (as service) to automator but nothing happens. For example that works well for me in terminal:

exiftool '-FileName<DateTimeOriginal' -d %y%m%d%H%M%S%%-c.%%le MyPhotoFolder

I try that in automator:

for f in "$@"
do
exiftool '-FileName<DateTimeOriginal' -d %y%m%d%H%M%S%%-c.%%le "$f"
done

Nothing happens. How can i run first one in automator in a folder?

Hi LacOniC,

Here are the steps to create an automator that works on the files/folders you give it:


  • Open automator and create a new Service type workflow
  • In the top area, set Service receives selected to Files or Folders in Finder
  • From the Utilities, drag Run shell script onto the workflow
  • Change the Pass input from stdin to as arguments (you'll see the script changes to a for loop)
  • Change the body of the script as you have specified as show below
  • Save the workflow under a logical name

for f in "$@"
do
    exiftool '-FileName<DateTimeOriginal' -d %y%m%d%H%M%S%%-c.%%le "$f"
done


You now have created a service that can be run on any folder/file in the finder. Beware, however that you will see NO output as the script is just run directly and not in e.g. a terminal window! If you want this, you'll have to program this specifically...

Hayo Baan – Photography
Web: www.hayobaan.nl

Phil Harvey

I guess I should have kept my mouth shut. :P

Hayo to the rescue! :)

- 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 ($).

LacOniC

Thank you Hayo. I found the solution before i read your post and your steps also include it. It was not the code. It was "pass input". I was using "stdin" because of a blog post that i used as reference. When i changed it to "arguments" all worked perfectly. Loop works but i don't need it because i use it only for one folder that i put new images. So i used a single line code that let me to select individual photos or a folder:

exiftool '-FileName<DateTimeOriginal' -d %y%m%d%H%M%S%%-c.%%le "$@"





Hayo Baan

Excellent, glad you found it and things are working well. And yes, you're right about the for loop of course  :)
Hayo Baan – Photography
Web: www.hayobaan.nl

LacOniC

After "OS X El Capitan" i started to get a weird error: -: exiftool: command not found

I reinstalled Exiftool. It works normally in terminal. But as a service, it does not. :)

Phil Harvey

The problem is that the ExifTool directory (/usr/local/bin) isn't in the path for the service.  If you specify the full path it should work (/usr/local/bin/exiftool).

- 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 ($).