ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Coding Snacks

Open files and rename or save as with new file name

(1/3) > >>

KaysLover:
I have a lot of PDF files called file001/002….. (100’s of files), all 1 page documents.

Is it possible for some code that would open selected files, extract the description from the next line after the word Remittance and save the file with that name? Please note that there is a date format dd/mm/yyyy on the same line which is not required as part of the file name.

(e.g. file001/002 opened, the descriptions extracted would be ‘This is the file name for file 001’ and ‘The file name for file 002’,

Therefore file named file001 to be renamed This is the file name for file 001, file named file 002 should be renamed The file name for file 002.

If the files cannot be renamed but can be saved as with the required file name, than this would suffice as well. I am quite happy to delete the files manually.

Any assistance offered would be appreciated.

Codebyte:
I see what you're trying to accomplish although im not sure this way is the most efficient... Does this thread do anything for you: https://www.donationcoder.com/forum/index.php?topic=16467.0 ? If not, let me know...

rjbull:
XPDF contains a command-line tool called PDFtoText that can do what it says, provided the PDFs aren't image scans, and that they aren't locked.  You might try it, with an AWK script or, if you're lucky, something like Horst Schaeffer's LMOD to extract the relevant text, and use a batch file to do the renaming.

mouser:
I think this idea of a smart PDF file renamer is extremely useful, i've toyed around with writing it myself for a number of years but just never bit the bullet and i'd just as soon leave it for someone who is already familiar with working with pdf files.  I do think it's a great idea though.  Let us know if you find anything good.

rjbull's idea is not half-bad.. to combine a commandline text extractor with a renamer tool..

KaysLover:
Thanks for you input so far.

I have had a look rjbull recommendation, and not been too techie, I am finding it hard to work out how to do it.

If anyone can give further assistance of LMOD, then this would be appreciated.

As a short term measure, I am going into the PDFs extracting the required description, closing the file and renaming the file all manually.

Navigation

[0] Message Index

[#] Next page

Go to full version