Newbie running .bat scripts

Started by greeni67, October 23, 2012, 10:51:09 AM

Previous topic - Next topic

greeni67

Good Morning,
I am new to the exiftool, and find that it is an awesome tool. I have been able to make te tool do most of what I want to but I have hit a wall.
Here is the history and problem:
I am trying to make preview images for multiple cameras, with .CR2 images, at the same time in different folders and putting the preveiw images into another folder. I want to keep the command 'open' as possible and not have a set naming convention. The reason for this I will be dealing with up to 5 trips, 20 stops, and each stop may have up to 700 images. So I want to keep them in some sort of structure so it is easy to locate the images. The folder structure will stay the same but the name of the trip and stop will always change.

example
V:\BG\Cam_Raw\Trip_X\Camera1\Stop1\000026-092612164356-Cam1.CR2
V:\BG\Cam_Raw\Trip_X\Camera2\Stop1\000026-092612164356-Cam2.CR2

V:\BG\Cam_Raw\Trip_Y\Camera1\Stop2\000034-092612174556-Cam1.CR2
V:\BG\Cam_Raw\Trip_Y\Camera2\Stop2\000034-092612174556-Cam2.CR2

I want the previews to be placed here:
V:\BG\Cam_Raw\Trip_X\Camera1\Preview\Stop1\000026-092612164356-Cam1_CR2.jpg
V:\BG\Cam_Raw\Trip_X\Camera2\Preview\Stop1\000026-092612164356-Cam2_CR2.jpg

V:\BG\Cam_Raw\Trip_Y\Camera1\Preview\Stop2\000034-092612174556-Cam1_CR2.jpg
V:\BG\Cam_Raw\Trip_Y\Camera2\Preview\Stop2\000034-092612174556-Cam2_CR2.jpg


This is the command for the exiftoolgui taht works:

-previewimage -b -r -w %-:1d\preview\%f_%e.jpg

This command works it will create previews for all subdirectoriesand place them into a preview folder up one step.

Now I am trying to doe the same thing but using the command line procedure and a .bat script.

Here is the .bat command that semi-works:

exiftool -previewimage *CR2 -b -w %%-:1d\preview\%%f_%%e.jpg -r

The issue I am having is that the .bat script only works in the folder that I have the exiftool and .bat in and doesn't look in other subfolder (-r). Also when I run the .bat script it creates a preview folder in the root folder for the drive I am working in and puts the previews there.

Questions:
1. How do I make the script run on all subdictorries?
2. Can the script place the prveiws up one folder step?

Thank You
Ben G

Phil Harvey

Hi Ben,

I'll try to answer your questions:

1. The -r option is only useful if you specify a directory name.  Use "-ext cr2 ." instead of "*.CR2" in your command.

2. I think this option will place the previews where you want:  -w %-:1d/Preview/%-1:d/%f_%e.jpg

An explanation of the directory format codes I used:

%-:1d = up one level (all directories except the bottom one)
%-1:d = the name of the bottom directory

This may seem odd, but in general it may make more sense:

%-N:Md = take N directory levels, skpping the bottom M.  If N is not specified, all levels are taken.  If M is not specified, no levels are skipped.  (Without the "-", levels are counted from the top instead of the bottom.)

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

greeni67

Phil
That works wonders for me. It works great on a test set that I have, now I am running it on a full set.

Thank you again
Ben G

greeni67

Phil
This off the subject of the tread, does Exiftools have the ability to attach GPS coordinates from a KML track to raw CR2, or preveiw jpg's of the CR2?

In the prvious post I used Exiftool to create a preview image of a CR2, in the raw format the CR2 does not have GPS data embedded in it. I have a text file for all the photo location that I imported into Google Earth and exported as a KML, with all the metadata for the images.

Thanks
Ben G

Phil Harvey

Hi Ben,

Quote from: greeni67 on October 24, 2012, 02:15:55 PM
does Exiftools have the ability to attach GPS coordinates from a KML track to raw CR2, or preveiw jpg's of the CR2?

Yes.  Provided the KML track has timestamps, you can use the -geotag feature to do this.

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

greeni67

Phil

I got the batch to work last week, thank you for help.

I just got back from a short trip and started looking at the prveiw images. In the ExifToolGUI I can look at the original CR2's the metadata for each images is pretty extensive.
When I process the previews with the .bat script it seems that all the original metadata from the CR2's is stripped out. Here is the script:

exiftool.exe -previewimage -ext cr2 . -b -r -w %%-:1d/preview/%%-1:d/%%f_%%e.jpg -pause

Is the stripping of data normal? Did I miss something in the script to keep it?

I also have some more questions about GeoTagging, but I will ask those after I figure this one out.

Thanks Again

Phil Harvey

Typically the preview images contain no metdata.  But you can copy the metadata from the CR2 to the preview:

exiftool -tagsfromfile @ -ext cr2 -srcfile %%-:1d/preview/%%-1:d/%%f_%%e.jpg -r DIR

This is considered advanced because the -srcfile option can be confusing, but here I thought it might be simpler to key off the CR2 images rather than the previews since then it uses the same file specification for the preview as in your other 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 ($).

greeni67

Phil
I got the metadata into the previews, it worked really good. Now I am on to trying to geotag the previews. I have a KML that has a field for TimeStamp (using GPS time) and a field for UTC -5:00. Here is the command I am running with the warnings that follow:

exiftool -geotag Photo_Index_Sample_2.kml -geotime="2012:09:26 16:43:43-05:01:03" 000025-092612164358-Cam1_CR2.jpg
Warning: No track points found in GPS file 'Photo_Index_Sample_2.kml' in File:Geotag (ValueConvInv)
Warning: GPS track is empty in File:Geotime (ValueConvInv)
Nothing to do.

Attached are the sample JPG and KML and TXT file, could you look at them and see if I need to change any of the fields or if my command is looking at the wrong field?

Thank you
Ben

greeni67

I guess the preview images are to large for me to upload, is there another way I can get them to you?

Phil Harvey

The problem is that the information is in a format that I've never seen before.  It is in a weird ExtendedData structure instead of the standard KML TimeStamp and Point properties, which look like this:

    <Placemark>
        <TimeStamp>
          <when>1997-07-16T10:30:15+03:00</when>
        </TimeStamp>
        <Point>
            <altitudeMode>absolute</altitudeMode>
            <coordinates>13.3307611167,52.50967085000001,22.5</coordinates>
        </Point>
    </Placemark>


If you could generate a standard KML placemark like this, then it should work.

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

greeni67

Something like this

Phil Harvey

#11
Not quite.  Your placemark now looks like this:

    <Placemark>
        <ExtendedData>
            <SchemaData schemaUrl="#S_Photo_Index_SSSSSIISSSI">
                <SimpleData name="DATE">9/26/2012</SimpleData>
                <SimpleData name="TimeStamp">319438.330</SimpleData>
                <SimpleData name="WGS_LONGITUDE">-94.8175604</SimpleData>
                <SimpleData name="WGS_LATITUDE">30.9905448</SimpleData>
                <SimpleData name="UTC_TIME">16:43:43.330</SimpleData>
            </SchemaData>
        </ExtendedData>
        <Point>
            <coordinates>-94.81756040000001,30.99054480000002,0</coordinates>
        </Point>
    </Placemark>


The "Point" is correct, but the TimeStamp is still hidden in a SimpleData property.  Also, the format of the TimeStamp value must be "yyyy-mm-ddThh:mm:ss+hh:mm"

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