#!/usr/bin/perl # the above is the standard linux/unix path for perl: change if your computer is nonstandard #use IO::CaptureOutput qw/capture_exec/; # requires: libio-captureoutput-perl ! # needs exiftool !! sub print_help { print STDERR < $figdir\n"; if(!-d $figdir){ `mkdir $figdir`; if(!-d $figdir){ die "could not create folder $figdir\n"; } print "created new folder $figdir\n"; } if(-e "$figdir/$f"){ print "warning: target file $figdir/$f exists: leaving $d/$f unmoved\n"; }else{ `mv -n \"$d/$f\" $figdir`; } if(-e "$d/$f" || !-e "$figdir/$f"){ print "warning: could not move file $d/$f into folder $figdir\n"; } if($replaced eq "no"){ $oldf=$f; $olddate=$date; $oldfigdir=$figdir; } } # could reconstruct a reasonable date for $f } # $f loop if(rmdir $d){ $verbosity==0 || print "removed empty folder $d\n"; }else{ print "could not remove (not empty) folder $d\n"; } }else{ # if $d is a proper directory print "ignored folder $d due to its name having the yyyy_mm_dd structure\n"; } } # $d loop sub getdata{ # extract the exif data from a jpeg file specified as argument local($_); $file = $_[0]; $_=`exiftool -q -T -createdate \"$file\"`; if($_==""){ $_=`exiftool -q -T -FileModifyDate \"$file\"`; } # old implementation (very slow!!): # $_=`identify -quiet -format "%[EXIF:DateTime]" \"$file\"`; # $_=`identify -quiet -format "%[EXIF:*]" \"$file\" | awk 'BEGIN{FS="="}/DateTime/{print \$2; exit}'`; chomp; s/([^\s]+)\s.*/\1/g; s/-//g; $_; }