From c7338422f28ac98d0d38ebf5b593ae70e98f0bda Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Mon, 21 May 2018 20:35:42 +0200 Subject: rename-pix-by-time-and-cam: better handling for date/time fields --- rename-pix-by-time-and-cam | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/rename-pix-by-time-and-cam b/rename-pix-by-time-and-cam index e2c7958..3a6224f 100755 --- a/rename-pix-by-time-and-cam +++ b/rename-pix-by-time-and-cam @@ -45,8 +45,9 @@ ids.each do |i| begin if timestamp t = timestamp.split(':',2)[1].strip.gsub(/(:|\ )/, '-') - elsif timestamp_bak - t = timestamp_bak.split(':',2)[1].strip.gsub(/(:|\ )/, '-') + end + if timestamp_bak + t_bak = timestamp_bak.split(':',2)[1].strip.gsub(/(:|\ )/, '-') end if cam c = cams[cam.split(':',2)[1].strip] @@ -55,16 +56,19 @@ ids.each do |i| else c = "unknown-device" end + if t.split('-').first.to_i < 2000 + t = t_bak + if not t or t.split('-').first.to_i < 2000 + puts "metadata unreasonable for #{i}, skipping!" + skip = true + end + end new_prefix = "#{t}-#{c}" add = 1 rescue puts "Can't find metadata for #{i}, skipping!" skip = true end - if t.split('-').first.to_i < 2000 - puts "metadata unreasonable for #{i}, skipping!" - skip = true - end next if skip while used_prefixes.has_key? new_prefix new_prefix = "#{t}-#{add}-#{c}" -- cgit v1.2.3