WelcomeUser Guide
ToSPrivacyCanary
DonateBugsLicense

©2026 Poal.co

(post is archived)

[–] 0 pt

I need a program that processes all the images in a directory, OCRing each image, and then renames it with the first X characters of the text from the image. I want to be able to specify X.

[–] 1 pt
#!/usr/bin/env ruby

X = 5

Dir.each_child('/path/to/dir') do |original_filename|
  ocr_text = RTesseract.new(filename).to_s
  new_filename = ocr_text.slice(0, X)
  File.rename(original_filename, new_filename)
end
[–] 0 pt

https://pypi.org/project/pytesseract/

I'm sure there's some Github project out there that does what you want, but you could always just write one yourself. Doesn't sound too difficult.