Created
          August 28, 2014 05:07 
        
      - 
      
 - 
        
Save stefanymarie/e953fd002e55a0f4aeb4 to your computer and use it in GitHub Desktop.  
    Rename Files with creation date from EXIF tag
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/bin/bash | |
| # The directory where the photos are | |
| SOURCE_DIR=/home/sserino/Pictures/PROCESS/Old | |
| # The destination directory | |
| DEST_DIR=/home/sserino/Pictures/PROCESS/Renamed | |
| # The date pattern for the destination dir (see strftime) | |
| DEST_DIR_PATTERN="%Y_%m_%d_%H_%M_%S" | |
| # Move all files having this extension | |
| EXTENSION=jpg | |
| IFS=$'\n' | |
| for f in $(find "$SOURCE_DIR" -iname "*.$EXTENSION" -type f) ; do | |
| # Obtain the creation date from the EXIF tag | |
| f_date=`exiftool $f -CreateDate -d $DEST_DIR_PATTERN | cut -d ':' -f 2 | sed -e 's/^[ \t]*//;s/[ \t]*$//'`; | |
| # Construct and create the destination directory | |
| #f_dest_dir=$DEST_DIR/$f_date | |
| #if [ ! -d $f_dest_dir ]; then | |
| #echo "Creating directory $f_dest_dir" | |
| #mkdir $f_dest_dir | |
| #fi | |
| mv "$f" "$DEST_DIR/IMG_$f_date.jpg" | |
| echo "Moved $f to $DEST_DIR/$f_date.jpg" | |
| done | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment