def adjust_metadata(folder_path)
pattern = /(\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2}_\d{3})\.\w+$/
Dir.foreach(folder_path) do |file|
next if file == '.' || file == '..'
match = file.match(pattern)
if match
timestamp = match[1]
full_path = File.join(folder_path, file)
`exiftool -overwrite_original -DateTimeOriginal=#{timestamp} -FileModifyDate=#{timestamp} -CreateDate=#{timestamp} "#{full_path}"`
puts "Metadata adjusted for file: #{file}"
end
end
end
adjust_metadata('./folder_name')
Created
April 13, 2024 15:30
-
-
Save kirillshevch/edc30a28e5437e436ece461adc3fed1c to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment