#This script searches the downloads folder for files with the '.jpg' or '.png' extension #It then moves them to the 'screenshots' folder on the desktop, and uses the 'tesoract' API to OCR them. require 'Rtesseract' require 'fileutils' class Screenshottaker #Allows us to read from and write to the 'folder' variable attr_accessor :folder public #Constructor def initialize(folder, destination) #In the future, could allow the user to tell the program where to look for the screenshots, but for now we will just hard-code downloads @folder = folder @destination = destination end #Find files in the Downloads folder with the .png or .jpeg extension def findFiles() Dir.chdir folder puts Dir.pwd #Get a list of all files with the extensions we care about @filelist = Array.new() Dir.glob('*jpg').each do|f| @filelist << f end Dir.glob('*png').each do|f| @filelist << f end Dir.glob('*pdf').each do|f| @filelist << f end puts @filelist.inspect #Now copy the files to the 'screenshots' folder @filelist.each do |file| FileUtils.cp(file, @destination) end end def ocr() puts @filelist.inspect end end #Create an instance of the ScreenshotTaker class def main() screenshottaker = Screenshottaker.new("/users/jbottom/Downloads", "/users/jbottom/Desktop/screenshots") screenshottaker.findFiles() screenshottaker.ocr() end main()