Created
April 20, 2024 21:20
-
-
Save jubishop/56b0b419817b33bff3824496ebfa1041 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env ruby | |
require 'set' | |
def parse(filename) | |
if filename.start_with?('clip') | |
return filename.match(/^clip-(\d+)-(\d+)-(\d+)\s+(\d+);(\d+);(\d+)/).captures | |
else | |
return filename.match(/^(\d+)-(\d+)-(\d+)\s+(\d+)\.(\d+)\.(\d+)/).captures | |
end | |
end | |
def stamp(filename) | |
puts "Now stamping #{filename}" | |
year, month, day, hour, minute, second = parse(filename) | |
`SetFile -d "#{month}/#{day}/#{year} #{hour}:#{minute}:#{second}" "#{filename}"` | |
`exiftool "-datetimeoriginal<filecreatedate" "#{filename}"` | |
`rm "#{filename}_original"` | |
end | |
Dir.glob('**/*.mp4').each { |filename| | |
stamp(filename) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment