Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.4: Prevent accidental overwriting of web receipts files System 10.4
I have been saving receipts, order confirmations, and so on from web commerce sites using the built-in Save PDF to Web Receipts Folder workflow in the "PDF" dropdown of the print dialog box. I was very surprised to learn (and you might be too) that this workflow silently overwrites existing files with the same name! Since it derives the file name from the web browser's window title (which in turn is derived from the tag of the web page), you can find yourself saving today's receipt from BogusSales.com, while clobbering your previous receipt from the same vendor (since the window likely has the same name on both occasions). You don't get a chance (1) to set the filename to something meaningful to you, or (2) to confirm that you want to overwrite.

But suppose you want to protect yourself from unintended file overwrites. You can always use Save as PDF instead, and enter your own filename and navigate to a storage location. That approach is safe, but lacks the one-click elegance of the Web Receipts solution. Also, the default Web Receipts folder may not be in the location you prefer. Can it be customized? Since Save PDF to Web Receipts Folder is simply an Automator workflow, you can modify it (or, to be safe, a copy of it) to better meet your needs.

Summary:

I opened the stock Web Receipts workflow in Automator. I was surprised to see it consists of a single step, New Folder, pointing to the Web Receipts folder. (If a folder with that name already exists, New Folder uses the existing folder; if files passed to New Folder, they are stored in the named folder.) So in front of that step, I added a Rename Finder Items action from the Finder library, and set the options to have it append the time of day to the filename of the file to be saved. That (almost assuredly) makes the filename unique, since the chance of twice saving a window with the same name at exactly the same hour, minute and second is remote.

I saved the copy in the PDF Services folder with a new name; it now appears automatically in the PDF drop-down in the Print dialog box. If you need more details on the how-to, read on...

Step-by-step:
  1. Open /Applications » Automator. A three-pane Untitled window will appear.
  2. Choose File » Open. Navigate to /Library » PDF Services. Click on Save to Web Receipts Folder, then Open. You should see the New Folder action in the right-hand pane.
  3. Choose File » Save As..., and enter a new name (such as My Web Receipts) and click Save.
  4. In the Automator window, in the left-hand (Library) pane, open the Applications disclosure triangle (if needed), and click on Finder. Finder-related actions should appear. Drag Rename Finder Items to the right-hand pane above the New Folder action. Rename... should have the number one next to it when you're done.
  5. If needed, open the disclosure triangle next to the number one. In the upper drop-down within the Rename Finder Items box, choose Add Date or Time. In the remaining drop-downs, choose values you prefer. I chose:
    • Date/Time: Current.
    • Where: After name.
    • Separator: None.
    • Format: Hour Minute Second.
    • Seperator: Underscore.
    • Use Leading Zeros.
  6. Check the Example filename at the bottom of the Rename Finder Items box to see that it looks as you expect.
  7. In the New Folder box, give the name and location of the folder where you want the web receipts to go.
  8. Choose File » Save.
That's it! Now you have your own customized Web Receipts going into your own location -- and with name-collision protection.
    •    
  • Currently 3.00 / 5
  You rated: 5 / 5 (7 votes cast)
 
[25,357 views]  

10.4: Prevent accidental overwriting of web receipts files | 19 comments | Create New Account
Click here to return to the '10.4: Prevent accidental overwriting of web receipts files' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: Prevent accidental overwriting of web receipts files
Authored by: jantonc on Feb 12, '07 08:23:39AM

Almost there - if you save 2 receipts on the same day they will overwrite.
In the "first" Rename Finder Items put the date *before* the filename.
Add a second Rename Finder and put the "Seconds from 12M" *after* the filename.

Now you will have DATE-title-SECONDS so you can save many receipts without overwriting, even if they are on the same day, with the same title.



[ Reply to This | # ]
10.4: Prevent accidental overwriting of web receipts files
Authored by: rusto on Feb 12, '07 08:51:06AM

Nice tweak, and nice hint. Quick and easy to implement!



[ Reply to This | # ]
10.4: Prevent accidental overwriting of web receipts files
Authored by: catodysseus on Feb 15, '08 07:47:55PM

I reworked the workflow from Tiger since the Leopard script is Phyhon!

The first Finder Rename adds HH-MM-SS
The second adds date YY-MM-DD

And then saved it to ~/library/pdf services/ (add the folder if missing) or to the folder library/pdf services/ for all users.

The automator script looks like this:[link:]http://tinyurl.com/2g5evn



[ Reply to This | # ]
10.4: Prevent accidental overwriting of web receipts files
Authored by: catodysseus on Feb 15, '08 08:06:38PM
I dont understand this link:-tag!

But here is a clickable link to my previous post:
http://tinyurl.com/2g5evn

[ Reply to This | # ]
10.4: Prevent accidental overwriting of web receipts files
Authored by: thermophile on Feb 12, '07 08:52:00AM
Great idea! I did one modification:
Step 5
I added a rename finder step with the following configuration:
  • Date/Time: Current
  • Where: Before
  • Separator: Space (your preference)
  • Format: Year Month Day
  • Separator: None
  • Use leading zeroes
This passes it to the second rename and results in the following:
20070212 page_name113000.pdf
Now the receipts can easily be sorted by name which sorts on day created.

[ Reply to This | # ]
10.4: Prevent accidental overwriting of web receipts files
Authored by: verdon on Feb 12, '07 10:11:44AM

Sadly, I just discovered this the other day, when looking at my receipts, expecting to find 50-60 of them, found less than a dozen.

Thanks for the tip.



[ Reply to This | # ]
10.4: Prevent accidental overwriting of web receipts files
Authored by: sirmarcos on Feb 12, '07 02:27:39PM

Yeah, that's frustrating that Apple just has it set to overwrite.

I made the changes here and in the comments and it's much better. It'd be nice to just be able to pick the file name though, in addition to adding date/time info. Not every web page has a sensible title!



[ Reply to This | # ]
10.4: Prevent accidental overwriting of web receipts files
Authored by: scbarton on Feb 12, '07 03:42:48PM

I just put an alias called "Receipts" in ~/Library/PDF Services that points to my desired destination folder. This creates an item in the PDF Services menu of the same name.

As far as I can tell, PDFs sent to to this menu item are automatically renamed to avoid overwriting.



[ Reply to This | # ]
10.4: Prevent accidental overwriting of web receipts files
Authored by: Dephex Twin on Feb 12, '07 04:48:01PM

THANK YOU.

I had wanted to do this and fiddled around on multiple occasions but never quite worked it out. And I certainly did *not* know that this script was silently overwriting my files. (That's really a boneheaded move on Apple's part.) So, thanks a million for pointing that out! I have been making heavy use of that script over the past few years and I am sure many things have gone missing as a result.

---
"Knicks suck, Yankees suck, Mets suck..."
"...Krypton sucks"



[ Reply to This | # ]
10.4: Prevent accidental overwriting of web receipts files
Authored by: joh on Feb 13, '07 06:29:33AM

You should really report the overwriting as a bug to Apple. Having such a service overwriting older receipts with the same name surely defeats the sole purpose of that service. Adding date/time or a sequence number is not only a nice idea, it's actually required for such things, especially when the file name is taken from the title of a webpage.



[ Reply to This | # ]
10.4: Prevent accidental overwriting of web receipts files
Authored by: Barney-15 on Feb 13, '07 10:05:39AM

This is all nice, and the recommendation to send in a bug report is good, but just do what scbarton said and put an alias to any folder in the PDF Services folder. Select that folder in the PDF dropdown and it will append a 2, 3, 4, etc as needed as new files with same name are added.

Really, the hint should be don't use Save to Web receipts folder, but instead, add an alias to any folder and save the web receipts there.

---
Jim



[ Reply to This | # ]
10.4: Prevent accidental overwriting of web receipts files
Authored by: kholburn on Feb 14, '07 05:02:20AM

Actually the alias is not a good solution for a multi-user machine.

Adding the date and time to the automated PDF workflow is a good idea except it may be written over in a future update/bugfix.

Maybe making a copy and changing the name and disabling the real web-receipts button would also be wise.



[ Reply to This | # ]
10.4: Prevent accidental overwriting of web receipts files
Authored by: BiL Castine on Feb 14, '07 05:50:28AM

on a multi-user machine you'd put the new aliases in /Users/username/library/PDF Services, not in /Library/Pdf Services. that way the folders would point to folders iset up for each individual user. the automator workflow just insured the Web Receipts folder gets created in the first place. personally i have 3 folders: Banking, Web and Billing Receipts.



[ Reply to This | # ]
10.5: Python
Authored by: Mechcozmo on Nov 10, '07 01:53:36PM

There's now a "Save PDF to Web Receipts Folder.pdfworkflow" which no app on my computer can open. Inside this package is an application called "tool" which happens to have been written in Python.

Apple now just tacks numbers onto the end of the filename if it isn't unique. Sort of ineloquent, but it works. At least it doesn't overwrite data anymore, but the filenames are less useful than the Tiger hint made them.



[ Reply to This | # ]
10.5: Python
Authored by: earlshango on Dec 01, '07 01:55:20PM

The 10.5 workflow (as of 10.5.1) seems to choke on webpages with the / character in the title, like "Order / Thank You."



[ Reply to This | # ]
10.4: Prevent accidental overwriting of web receipts files
Authored by: jtrevorchapman on Dec 16, '07 11:45:10PM

How do I get this to work on 10.5

When I go into /library/ PDF services

I get a workflow that looks like this: Save PDF to Web Receipts Folder.pdfworkflow

It won't open in automator, even when I open it arbitrarily.

Please HELP!



[ Reply to This | # ]
10.4: Prevent accidental overwriting of web receipts files
Authored by: jpravetz on Jan 03, '08 01:00:40PM

As pointed out, this is now a python script in 10.5. You can directly edit the "tool" file at /Library/PDF Services/Save PDF to Web Receipts Folder.pdfworkflow/Contents to add the behaviour you want. I, for example, changed the default save folder, and added/changed these lines:

import datetime
# Create a YYYYMMDD string
today = datetime.datetime.now().strftime("%Y%m%d_")
destFile = today + title + ".pdf"

This is the first time I've edited python, but it seems to work.



[ Reply to This | # ]
10.4: Prevent accidental overwriting of web receipts files
Authored by: jgarbers on Jan 28, '08 11:32:12AM

I'd like to be able to review and edit the name of the file before it gets saved -- to include the name of the product I just bought or registered rather than a generic title from Kagi, for example. Seems like this would be trivial but I have no Automator experience at all. Anybody have a suggestion about how to make a "Save to Web Receipts" that also lets you change the name? "Save as PDF..." alone would be OK except that it doesn't default to the "Web Receipts" folder.



[ Reply to This | # ]
10.4: Prevent accidental overwriting of web receipts files
Authored by: Kapila on Sep 09, '09 06:25:11AM
Tip for those who know a bit of Python and Terminal/vi:
  1. Open the following file in vi
    vi "/Library/PDF Services/Save PDF to Web Receipts Folder.pdfworkflow/Contents/Tool"
  2. Change the following Python code:
    import sys
    
    def safeFilename(filename):
        filename = filename.lstrip('.')
        filename = filename.replace(os.path.sep, '-')
        if len(filename) == 0:
            filename = "Untitled"
        elif len(filename) > 245:
            filename = filename[0:245]
        return filename
    
    to be:
    import sys
    import datetime
    
    def safeFilename(filename):
        filename = filename.lstrip('.')
        filename = filename.replace(os.path.sep, '-')
        if len(filename) == 0:
            filename = "Untitled"
        elif len(filename) > 200:
            filename = filename[0:200]
    
        now = datetime.datetime.now()
        stamp = now.strftime("_%Y%m%d_%H%M%S")
        return filename + stamp
    


[ Reply to This | # ]