Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: How best to rename all JPEGs in a folder by EXIF date & time stamp

  1. #1
    Join Date
    Aug 2010
    Beans
    407
    Distro
    Ubuntu 10.04 Lucid Lynx

    How best to rename all JPEGs in a folder by EXIF date & time stamp

    In the Windows world where I came from, Irfanview freeware easily renamed a large folder of JPEG photos by EXIF time & date stamps, appending a unique number if the time and date stamps were the same.

    Is there an equivalent rename-by-EXIF information batch command in Ubuntu 10.04 Lucid?

    For example, change (based solely on EXIF information):

    • FROM:
      • DSC_0001.JPG

    • TO:
      • 20110224_09:34:56am.JPG


  2. #2
    Join Date
    Aug 2010
    Beans
    407
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: How best to rename all JPEGs in a folder by EXIF date & time stamp

    Nobody?

  3. #3
    Join Date
    Oct 2009
    Beans
    2,199
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: How best to rename all JPEGs in a folder by EXIF date & time stamp

    Well. There is a command line program called exif that might be worth looking into.
    I gave up on easy methods and ended up writing a Java program to do it.

  4. #4
    Join Date
    Aug 2010
    Beans
    407
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: How best to rename all JPEGs in a folder by EXIF date & time stamp

    Quote Originally Posted by YesWeCan View Post
    There is a command line program called exif that might be worth looking into
    Thanks for the idea. It failed, but, I do appreciate the assistance (especially since I had not known about "exif" as a program).

    I installed "exif" along with "exiftran" which I already had.

    Both seem to do the same thing, which is spit out EXIF information.

    But, neither will rename a file based on the EXIF time and date.

    So, it looks like I too will need to write a program to convert that information to a program for changing file names of directories of photographs.

    Sigh. You'd think we're not the first Ubuntu people to want this capability of naming photographs based on the time and date taken since this is a common feature in Windows freeware.

    Here is how I obtained the help for "/usr/bin/exif", for example:
    Code:
    $ man exif | col -b > /tmp/exif.man
    $ vi !$
    
      exif(1)            command line front-end to libexif           exif(1)
     NAME
            exif - shows EXIF information in JPEG files
     SYNOPSIS
            exif [ OPTION ] [ file... ]
    
     DESCRIPTION
            exif  is  a small command-line utility to show and change EXIF informa‐
            tion in JPEG files.
     
    
            Most digital cameras produce EXIF files,  which    are  JPEG  files  with
            extra  tags that contain information about the image. The exif command-
            line utility allows you to read EXIF information from  and  write  EXIF
            information to those files.  exif internally uses the libexif library.
     
    
            Each  input file given on the command line is acted upon in turn, using
            all the options given. Execution will be  aborted  immediately  if  one
            file is not readable or does not contain EXIF tags.
     
    
            As  EXIF  tags  are read, any unknown ones are discarded and known ones
            are automatically converted into the correct  format,  if  they    aren't
            already.   Corrupted  MakerNote    tags  are  also removed, but no format
            changes are made.
     
    
     OPTIONS
            -v, --version
               Display the exif version number.
     
    
            -i, --ids
               Show ID numbers instead of tag names.
     
    
            -t, --tag=TAG
               Select only this TAG.  TAG is the tag title, the short tag name,
               or  the  tag  number (hexadecimal numbers are prefixed with 0x),
               from the IFD specified with --ifd.  The tag title  is  dependent
               on  the current locale, whereas name and number are locale-inde‐
               pendent.
     
    
            --ifd=IFD
               Select a tag or tags from this IFD.  Valid IFDs  are  "0",  "1",
               "EXIF", "GPS", and "Interoperability".  Defaults to "0".
     
    
            -l, --list-tags
               List  all  known    EXIF tags and IFDs.  A JPEG image must be pro‐
               vided, and those tags which appear in the file are shown with an
               asterisk in the corresponding position in the list.
     
    
            -|, --show-mnote
               Show  the  contents  of the MakerNote tag.  The contents of this
               tag are nonstandard (and often undocumented) and    may  therefore
               not be recognized, or if they are recognized they may not neces‐
               sarily be interpreted correctly.
     
    
            --remove
               Remove the tag or (if no tag is specified) the entire IFD.
     
    
            -s, --show-description
               Show description of tag.    The --tag option must also be given.
     
    
            -e, --extract-thumbnail
               Extract the thumbnail, writing the thumbnail image to  the  file
               specified with --output.
     
    
            -r, --remove-thumbnail
               Remove  the  thumbnail  from the image, writing the new image to
               the file specified with --output.
     
    
            -n, --insert-thumbnail=FILE
               Insert FILE as thumbnail.  No attempt is made to ensure that the
               contents of FILE are in a valid thumbnail format.
     
    
            --no-fixup
               Do not attempt to fix EXIF specification violations when reading
               tags.  exif will remove illegal or unknown tags, add some manda‐
               tory tags using default values, and change the data type of tags
               to match that required by the specification.
     
    
            -o, --output=FILE
               Write output image to FILE.  If this option is not given and  an
               image  file  must  be  written, the name used is the same as the
               input file with the suffix ".modified.jpeg".
     
    
            --set-value=VALUE
               Set the data for the tag    specified  with  --tag    and  --ifd  to
               VALUE.   Compound  values  consisting of multiple components are
               separated with spaces.
     
    
            -c, --create-exif
               Create EXIF data if it does not exist
     
    
            -m, --machine-readable
               Produce output in  a  machine-readable  (tab-delimited)  format.
               The  --xml-output  and  --machine-readable  options are mutually
               exclusive.
     
    
            -w, --width=N
               Set the maximum width of the output  to  N  characters  (default
               80). This does not apply to some output formats (e.g. XML).
     
    
            -x, --xml-output
               Produce output in an XML format (when possible).    The --xml-out‐
               put and --machine-readable options are mutually exclusive.
     
    
            -d, --debug
               Show debugging messages. Also, when processing a file that  con‐
               tains corrupted data, this option causes exif to attempt to con‐
               tinue processing. Normally, corrupted data causes an abort.
     
    
        Help options
            -?, --help
               Show help message.
     
    
            --usage
               Display brief usage message.
     
    
     EXAMPLES
            Display all recognized EXIF tags in an image and the tag contents, with
            bad tags fixed:
     
    
               exif image.jpg
     
    
            Display a table listing all known EXIF tags and whether each one exists
            in the given image:
     
    
               exif --list-tags --no-fixup image.jpg
     
    
            Extract the thumbnail into the file thumbnail.jpg:
     
    
               exif --extract-thumbnail --output=thumbnail.jpg image.jpg
     
    
            Display a list of the numeric values of    only  the  EXIF  tags  in  the
            thumbnail IFD (IFD 1) and the tag values:
     
    
               exif --ids --ifd=1 --no-fixup image.jpg
     
    
            Display    the  meaning  of tag 0x9209 in the "EXIF" IFD according to the
            EXIF specification:
     
    
               exif --show-description --ifd=EXIF --tag=0x9209
     
    
            Add an Orientation tag with value "bottom - left" to an existing image:
     
    
               exif   --output=new.jpg    --ifd=0   --tag=0x0112     --set-value=4
               --no-fixup image.jpg
     
    
            Add  a  YCbCr Sub-Sampling tag with value 2,1 (a.k.a YCbCr 4:2:2) to an
            existing image and fix the existing tags, if necessary:
     
    
               exif     --output=new.jpg     --tag=YCbCrSubSampling     --ifd=0
               --set-value='2 1' image.jpg
     
    
     AUTHOR
            exif  was  written  by  Lutz  Mueller  <lutz@users.sourceforge.net> and
            numerous contributors.  This man page is Copyright ©  2002-2009    Thomas
            Pircher and others.
     
    
     SEE ALSO
            http://www.sourceforge.net/projects/libexif
     
    
     
    
     
    
     exif 0.6.19              2009-11-12                   exif(1)
    Here is how I obtained the help for "/usr/bin/exiftran", for example:
    Code:
    $ man exif | col -b > /tmp/exiftran.man
    $ vi !$
    
    exiftran(1)                               exiftran(1)
    
     NAME
           exiftran - transform digital camera jpeg images
     
    
     SYNOPSIS
           exiftran [ options ] file(s)
     
    
     DESCRIPTION
           exiftran  is  a    command  line  utility to transform digital image jpeg
           images.    It can do lossless rotations like jpegtran, but  unlike  jpeg
           nail.  It can process multiple images at once.
     
    
     TRANSFORM OPTIONS
           -a     automatic (using exif orientation tag)
     
    
           -9     rotate by 90 degrees clockwise
     
    
           -1     rotate by 180 degrees clockwise
     
    
           -2     rotate by 270 degrees clockwise
     
    
           -f     flip vertical
     
    
           -F     flip horizontal
     
    
           -t     transpose
     
    
           -T     transverse
     
    
           -nt    Don't rotate exif thumbnail.
     
    
           -ni    Don't rotate jpeg image. You might  need    this  or  or  the  -nt
               option  to  fixup things in case you rotated the image with some
               utility which ignores the exif thumbnail. Just generating a  new
               thumbnail with -g is another way to fix it.
     
    
           -no    Don't  update the orientation tag.  By default exiftran sets the
               orientation to "1" (no transformation  needed)  to  avoid  other
               exif-aware  applications try to rotate the already-rotated image
               again.
     
    
     OTHER OPTIONS
           -h     print a short help text
     
    
           -d     Dump exif data for the file(s).
     
    
           -c <text>
               Set jpeg comment tag to <text>.
     
    
           -g     (re)generate EXIF thumbnail.
     
    
           -o <file>
               Specify output file.  Only one input file  is  allowed  in  this
               mode.
     
    
           -i     Enable  inplace editing of the images.  Exiftran allows multiple
               input files then.  You must specify either this option or a out
           CHANTABILITY  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
           Public License for more details.
     
    
           You should have received a copy of the GNU General Public License along
           with this program; if not, write to the Free Software Foundation, Inc.,
           675 Mass Ave, Cambridge, MA 02139, USA.
                     (c) 2003,04 Gerd Knorr           exiftran(1)
    Last edited by rocksockdoc; March 3rd, 2011 at 05:40 AM.

  5. #5
    Join Date
    Jul 2007
    Location
    Burlington, NC
    Beans
    1,995
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: How best to rename all JPEGs in a folder by EXIF date & time stamp

    pyRenamer can do this.

    Code:
    sudo apt-get install pyrenamer
    You have to pick the pictures location in the upper left pane.
    Then click the Image tab in the lower pane.

    For the replacement pattern, use something like "{imagedate}_{imagetime}".
    Using the "Preview" button is highly recommended .

    Quote Originally Posted by rocksockdoc View Post

    So, it looks like I too will need to write a program to convert that information

    Sigh. You'd think we're not the first Ubuntu people to want this capability…
    Surely you had plans to release this as open source and iron out
    the inevitable bugs reported by the community, yes?
    Last edited by asmoore82; March 3rd, 2011 at 05:39 AM.
    Give me Free Software or Give me Death!

  6. #6
    Join Date
    Dec 2008
    Beans
    13

    Re: How best to rename all JPEGs in a folder by EXIF date & time stamp

    I wasn't aware of pyrenamer, so maybe that solves your needs, OP. I can understand not wanting to "reinvent the wheel" if you don't have to, but another option would be to write your own custom script.

    Another thought: the command 'exiftags' also contains the timestamp information.

  7. #7
    Join Date
    May 2008
    Beans
    38

    Re: How best to rename all JPEGs in a folder by EXIF date & time stamp

    know this is a bit old post.. but the answer is exiv2.

    http://linux.die.net/man/1/exiv2

    "
    Examples

    exiv2 *.jpg
    Prints a summary of the Exif information for all JPEG files in the directory.
    exiv2 -pi image.jpg
    Prints the IPTC metadata of the image.
    exiv2 rename img_1234.jpg
    Renames img_1234.jpg (taken on 13-Nov-05 at 22:58:31) to 20051113_225831.jpg
    exiv2 -r':basename:_%Y%m' rename img_1234.jpg
    Renames img_1234.jpg to img_1234_200511.jpg

    "

    I wrote a script a few years ago to batch rename all my files by date and time very quickly... works like a charm for me. A simple bash loop can rename all your photos .. like 1000 .. in a minute or two.

    I'd recommend you work on copies first.

  8. #8
    Join Date
    Dec 2009
    Beans
    Hidden!

    Re: How best to rename all JPEGs in a folder by EXIF date & time stamp

    Code:
     for i in `ls | grep jpg`; do a=${i/.jpg/.$(date +%T).jpg} && mv "$i" "$a"; done
    why install something when you can handle it with bash

    Code:
    man sed
    man grep
    man date
    # do above for more info

  9. #9
    Join Date
    May 2008
    Beans
    38

    Re: How best to rename all JPEGs in a folder by EXIF date & time stamp

    Well, because as far as I can tell your script renames them to the current system date/time.. not the exif date of the photo which is what the poster wanted. If you have a way to do this in bash alone, please share.


    Consider this scenario... it happened to me many times.
    On vacation some place with 3 different cameras from 3 people...etc.

    Cameras typically name files using their own conventions.. NCDC, GEDC, etc.

    Therefore, when you put all the photo from the 3 cameras in the same folder, they are organized by Camera name not time taken. Renaming them by exif will nicely merge them all in the correct order.. so for example, you dont see Nikon Camera breakfast, lunch, dinner photos then see them all over again for the GE camera.


    Sorted by exif would look like this.

    08:17:30 Nikon Breakfast
    08:18:32 GE Breakfast
    13:46:22 GE Lunch
    13:59:55 Nikon Lunch

    It's much cleaner and less repetitive.

    Here's the basic code I use.. try yours then mine, especially under the scenarios given above, and see the difference.

    Code:
    for i in $(ls *.JPG); do exiv2 -r '%Y%m%d.%H%M%S.:basename:' rename $i; done
    Last edited by jahst; April 5th, 2011 at 12:57 PM.

  10. #10
    Join Date
    Aug 2007
    Beans
    11

    Re: How best to rename all JPEGs in a folder by EXIF date & time stamp

    gthumb will do the job for you easily

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •