Code:
#!/bin/bash
src_dir=. # main dir (SCAN)
dest_dir=../new_pics # dir for resized stuff (RESIZE+MOVE)
log_dir=. #
log=pics_$( date +%F ).log # log name, not used yet
year=$( date +%Y ) # not used yet (MOVE)
# find latest log file
read _ lastlog < <( find "$log_dir" -iname '*.log' -printf "%T@\t%f\n" | sort -nr )
if [ "$lastlog" ]
then
log_ts=$( stat -c %y "$lastlog" ) # log timestamp for debugging
echo "latest log file: $lastlog ($log_ts)"
# prepare parameter list
scan_options=( "-newer" "$lastlog" "-iname" "*.jpg" )
else
scan_options+=( "-iname" "*.jpg" )
fi
# print find options
# for s in "${scan_options[@]}"; do echo "'$s'"; done
# find files newer than the log file (all files if there is no .log file)
files=()
while read -r -d $'\0' f
do
files+=( "$f" )
done < <( find "$src_dir" "${scan_options[@]}" -print0 )
# print files etc
for f in "${files[@]}"
do
echo "file: $f ($( stat -c %y "$f" )) > ($log_ts)"
# test if in proper format
# [[ $f =~ .+-.+-[0-9]+.jpg ]] && echo proper format || echo rename
done #> "$log_dir/$log"
that should find the files newer than the newest existing log file. Obviously variables at the top should be filled with proper values to point where they should.
It doesn't produce log by itself, i skipped that part as it would make debugging annoying (every run would create newer log and i'd have to roll its timestamp back or touch all dummy files - pain in the back when you have to do this every 10 seconds)
Create whatever .log file in proper location, use touch command to set it to some time, eg.
Code:
touch -d 'now -2 days' test.log
and see if the list is ok.
Could you elaborate more on the renaming part? What would the date format be exactly? And is the sequence global in the directory or maybe it is only related to subsets based on days?
Code:
global: day based:
abc-(yesterday)-001.jpg abc-(yesterday)-001.jpg
abc-(yesterday)-002.jpg abc-(yesterday)-002.jpg
abc-(today)-003.jpg abc-(today)-001.jpg
abc-(today)-004.jpg abc-(today)-002.jpg
Bookmarks