[opensuse] gphoto2 - download image file rename/classify helper script
All, Using gphoto2 to download, delete or upload images to apple devices is really handy, but the default filenames contained on the device are horrible. (non-descript, upper-case, etc..). For example, after downloading all images from your device you have a directory full of: 02:44 alchemy:~/mmedia/iPhone/iph3-black-sav> l1 IMG_0001.JPG IMG_0002.JPG IMG_0016.MOV IMG_0032.PNG IMG_0033.JPG IMG_0034.PNG IMG_0182.MOV IMG_0183.JPG IMG_0186.MOV IMG_0188.MOV IMG_0189.JPG IMG_0190.JPG ... This contains all images in the "camera roll" including photos, saved graphic files and videos. For permanent storage, I want the photos separated from the graphic and video files in a way that is easy to manage. If anyone has a similar issue, I've cobbled together a helper script to parse the file, examine the EXIF and PNG headers and rename them into separate directories with filenames that contain the image (or filemod) date along with the original image number for reference. Example: bkgnd img_20120102-195924_0024.jpg img_20120102-203607_0034.png images img_20120102-203551_0032.png img_20120102-203559_0033.jpg photos iPhone_3GS_20130509-154717_0470.jpg iPhone_3GS_20130707-142745_0517.jpg videos img_20111226-133705_0016.mov img_20120303-173828_0177.mov The help file for the script is fairly self-explanatory. The script takes either a single filename or directory as its only input and the {bkgnd,images,photos,videos} subdirs are created under the given file or directory path. The find statement used when a directory is passed to the script is limited to -maxdepth 1 so it only operates on a single directory. The help is: 02:53 alchemy:~/mmedia/iPhone> ~/scr/photo/iphrename.sh -h Usage: iphrename.sh /path/to/iPhone/image/download iphrename.sh reads a directory containing image filenames in the form IMG_####.EXT (as downloaded by gphoto2 from an iPhone) and performs an intelligent rename of the files and moves the files into the following subdirectories: bkgnd : background images, named img_YYYYMMDD-HHMMSS_####.ext (criteria: jpg/png horiz. image resolution <= 500) images : non-photo images, named img_YYYYMMDD-HHMMSS_####.ext (criteria: jpg/png horiz. image resolution > 500 && no EXIF camera model) photos : photo images, named <EXIF-model>_YYYYMMDD-HHMMSS_####.ext (criteria: jpg horiz. image resolution > 500 && EXIF camera model) videos : video images, named img_YYYYMMDD-HHMMSS_####.ext (criteria: .MOV extension) All filenames are translated to lowercase. '####' in the filename preserves the image number from the original filename (IMG_####.EXT) allowing complete reversal of the file rename. For photos, the YYYYMMDD-HHMMSS is the original camera image data generation date/time (if available), otherwise for jpeg images it is file creation date/time contained within the EXIF data. For PNG and MOV files, the YYYYMMDD-HHMMSS date/time is the file modification time as returned by 'stat -c%y'. Options: -h | --help program help (this file) If you are interested in the script, you can grab copy here: http://www.3111skyline.com/dl/linux/scripts/photo/iphrename.sh.txt I added a .txt extension so you could browse it on the web-server. It has reasonable comments, and as always use it, cannibalize it, whatever. If you, heaven forbid, find a screw-up in it, or (DH) see something that could be done better, just let me know. Thanks. -- David C. Rankin, J.D.,P.E. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On Sat, 2014-01-04 at 03:25 -0600, David C. Rankin wrote:
<snip>
If anyone has a similar issue, I've cobbled together a helper script to parse the file, examine the EXIF and PNG headers and rename them into separate directories with filenames that contain the image (or filemod) date along with the original image number for reference.
<snip>
This is very useful. Although I do not download pictures, this is a useful script. I will grab a copy in case it is required in future. With Kind Regards. Sudhir -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
* David C. Rankin
Using gphoto2 to download, delete or upload images to apple devices is really handy, but the default filenames contained on the device are horrible. (non-descript, upper-case, etc..). For example, after downloading all images from your device you have a directory full of:
02:44 alchemy:~/mmedia/iPhone/iph3-black-sav> l1 IMG_0001.JPG IMG_0002.JPG IMG_0016.MOV IMG_0032.PNG IMG_0033.JPG IMG_0034.PNG IMG_0182.MOV IMG_0183.JPG IMG_0186.MOV IMG_0188.MOV IMG_0189.JPG IMG_0190.JPG ...
This contains all images in the "camera roll" including photos, saved graphic files and videos. For permanent storage, I want the photos separated from the graphic and video files in a way that is easy to manage. If anyone has a similar issue, I've cobbled together a helper script to parse the file, examine the EXIF and PNG headers and rename them into separate directories with filenames that contain the image (or filemod) date along with the original image number for reference. Example:
bkgnd img_20120102-195924_0024.jpg img_20120102-203607_0034.png images img_20120102-203551_0032.png img_20120102-203559_0033.jpg photos iPhone_3GS_20130509-154717_0470.jpg iPhone_3GS_20130707-142745_0517.jpg videos img_20111226-133705_0016.mov img_20120303-173828_0177.mov
[...] I do something similar but much different. I am team photog for a regional travel soccer team and the local high school soccer team (grandson is goalie and high school was state runner up this year). I use Nikon gear and usually two cameras at each event. I time sinc the cameras before an event. After an event, I dl the photos from the flash cards via card reader to computer, lowercase the filenames, adjust file dates to the exif "Create Date", then rename the files by adding the Date-Time to the filename. Now my photos are time sequenced and identifiable. redate changes file date to exif "Create Date" lc;exiv2 -T ./*.{nef,jpg} rename2date exiv2 mv \-k \-r %y%m%d_%H%M%S_:basename: \.\/*.{nef,jpg}' lc = /usr/bin/lowercase_filenames ## from shtools ## obs://build.opensuse.org/home:hennevogel exiv2 rather than exiftool as exiv2 is compiled and *much* faster I also add location data as I am too cheap to buy the gps equipment which also depleates my batteries, using a free app on my android phone, GPSLogger. The app automagically emails me the gps coordinates and altitude which I add by script to the photos: gpsPhoto --dir ./ --geotag-source=option --geotag=39.685443,-86.274003,211.000000 (that's one liner) gpsPhoto (obs://build.opensuse.org/Application:Geo): A commandline tool to synchronize a gps (gpx) tracklog with the date/time stamps of the image exif-data gpsPhoto geotags digital photos by using GPS track data recorded at the same time. Matches are based on closest timestamps. An optionally generated Google Earth KML or KMZ file contains the GPS tracks and the geotagged photos. The purpose of this tool is to allow a hiker to record a GPS tracklog or waypoints and later (at home) synchronize this GPS data with the timestamps of the image exif data of his digital camera, in order to locate and store the position where the picture was taken. The tool writes coordinates, altitude and additional metadata to the Exif and IPTC metadata section of jpeg, nef and potentially other file formats. Optionally, a Google Earth kml file is created containing the gps tracklog and the image positions. ## Of little interest to most people ## But perhaps insight or suggestive in your application. ps: Weather was great, traffic much less so, on our pass across the South over holidays. Floated the San Antonio canals, visited Alamo and another mission and ate very good food. Galveston, New Orleans during the storm, but Orlando was upper 70s to lower 80s and partly sunny. Soccer events just so-so, 1-1-1, but venue marvelous. -- (paka)Patrick Shanahan Plainfield, Indiana, USA @ptilopteri http://en.opensuse.org openSUSE Community Member facebook/ptilopteri http://wahoo.no-ip.org Photo Album: http://wahoo.no-ip.org/gallery2 Registered Linux User #207535 @ http://linuxcounter.net -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
participants (3)
-
David C. Rankin
-
Patrick Shanahan
-
Sudhir Anand