Filename strip date and timestamp only from some files
Posted on 2011-10-21
I have 20 some reports printed to PDF from an access database. Depending on the report and the PDFCreator printer used (there are 2 printers with different naming profiles), some of the filenames end with a date and timestamp like shown below. All have different 'front end' names. This is by design as half the reports are designed to be run by individual users in different Teams to shared network directories and we need this info to keep versions straight for those reports.
reportname3 diff length name__20111021104244.pdf
reportname4 different length name__20111021114400.pdf
However, I do some 'batch' report processing and need to strip off just the underscore and date/timestamp extension for only the reports in the directory that have it (i.e reports 1, 3, 4 & 5) in example above so I have a group of files in a directory that are always have the same filenames no matter when I run them. About half the files have date/timestamps the other half don't, some reports that print real quickly in sequence will have same date/timestamp (but different report names).
The other option seems to be to re-create duplicates of all the reports and point the duplicate to the PDFCreator printer that doesn't add a date/timestamp. Then create separate forms/buttons, etc. etc. Long term this does not appear to be the best solution.
I am thinking that a VBA or VBS routine just to strip the extra info off if it is there would be easiest but don't know how to code this. I can imbed the VBA in Access as part of the 'batch' reporting other or call a VBS script within as well, but am open to other ideas if you can tell me how to incorporate into a call from Access.
Please ask questions if unclear and THANKS in advance!