summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Simianer <pks@pks.rocks>2018-05-21 20:35:42 +0200
committerPatrick Simianer <pks@pks.rocks>2018-05-21 20:35:42 +0200
commitc7338422f28ac98d0d38ebf5b593ae70e98f0bda (patch)
treef8d9b6b6674cb8da451b5a7bfb922041d4aaf303
parent92335d5ec53be870685e6f1797f69a21db5d435f (diff)
rename-pix-by-time-and-cam: better handling for date/time fields
-rwxr-xr-xrename-pix-by-time-and-cam16
1 files 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}"