Skip to content

Instantly share code, notes, and snippets.

@dallasread
Created September 22, 2016 15:31
Show Gist options
  • Save dallasread/cce21e921f85692d80f7260f1c65fceb to your computer and use it in GitHub Desktop.
Save dallasread/cce21e921f85692d80f7260f1c65fceb to your computer and use it in GitHub Desktop.
Find all files of a certain type from Messages
require 'shellwords'
username = "me"
filetype = ".pdf"
target = "/Users/#{username}/Desktop/pdfs"
source = "/Users/#{username}/Library/Messages/Attachments/**/*#{filetype}"
Dir[source].each do |file|
basename = File.basename(file)
`cp #{file} #{target.shellescape}/#{basename.shellescape}`
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment