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

Automatically change the name of screenshot files System
One of the side-effects of running The MacTipper Blog is that I take a lot of screenshots. Right now, I have more than 150 screenshots in my trash can. My point with all this is that I deal with a lot of screenshots. One of my complaints when dealing with screenshots is that you cannot quickly select a screenshot with the keyboard. To do that, I need to navigate to the folder, hit Tab, then type in Picture, press the Space Bar, then type the number of the screenshot I want.

In order to solve this, I have written a script to rename any of the default-named screenshot files to a name you prefer with the number before the name. For example, this script will change Picture 1.png to 1 Screenshot.png. Here's the script:
--Written by MacTipper for The MacTipper Blog: http://www.mactipper.com/2009/03/script-to-change-default-name-of.html
--This script allows you to change the default name of screenshots by combining it with a LaunchD script.
--Everything there is to know about screenshots: http://www.mactipper.com/2008/08/everything-there-is-to-know-about.html

property the_suffix : " Screenshot" --Everything that will appear after the number except for the extension.
property folder_path : "/Users/oliver/Pictures/Screenshots/" --Posix path to your screenshots folder. You can change the folder with this tip: http://tinyurl.com/changescreenshots
property default_extension : ".png" --Change this to the extension of screenshots you take.

on run
  tell application "Finder"
    set action_folder to ((POSIX file folder_path) as alias)
    set folder_items to every item in action_folder
  end tell
  repeat with an_item in folder_items
    tell application "Finder"
      set item_name to name of (an_item as alias)
      set the_comment to (get comment of (an_item as alias))
      log item_name
    end tell
    if the_comment does not contain "managed" then
      set an_item to (an_item as alias)
      if (item_name ends with default_extension) then
        if (item_name begins with "Picture") then
          set x to 0
          repeat
            set x to x + 1
            set the_name to (x & the_suffix & default_extension) as string
            set the_path to (POSIX file (folder_path & the_name)) as string
            tell application "Finder"
              try
                (the_path as alias)
              on error err
                log err
                if err is (("File " & the_path & " wasn't found.") as string) then
                  exit repeat
                else
                  return err
                end if
              end try
            end tell
          end repeat
          tell application "Finder"
            set comment of an_item to (comment of an_item) & " managed"
            set name of an_item to the_name
          end tell
          
        end if
      end if
    end if
  end repeat
end run
You can also download the script if you prefer. Once you've created/downloaded the script, you'll need to set it up.

Here's how to get the script working:
  1. Put the script in a safe place.
  2. Open up the script and edit the first three properties:
    • the_suffix: This is what will come immediately after the number.
    • folder_path: This is the folder that your screenshots reside in; most likely it is your desktop. To change this, delete the text that is already there, and drag in the folder that you use. If you are asked if you want to copy the files in, simply select the 'Alias' option. Make sure that there is a trailing slash.
    • default_extension: Put in the extension of screenshots you take. Make sure there is a leading dot.
    Once you're done editing the AppleScript, save it with Command-S.
  3. If you don't already have it, go get Lingon.
  4. Open up Lingon and make a new script by hitting Command-N.
  5. In the first dialog, select My Agents. For the name, use something like com.mactipper.screenshots.folderaction or anything else that you know will be unique. It is important that it has a unique name.
  6. For the 'What', type in osascript, press the Space Bar, then type a double-quote mark ("), then drag in the script you edited. Finally, end it with another double-quote mark.
  7. For the 'When', set Run it if this file is modified box to the folder that your screenshots go to. To make sure this is done properly, click on the text box then drag in the folder from Finder and drop it onto the box. Finally, add a trailing slash (/) to the file name.
  8. Hit Command-S to save the script.
  9. Restart your computer to load the launchd script.
Take a screenshot to make sure everything works. Note that the script can sometimes take a couple seconds to take action, but it does do the trick. If you need more details on the process, this post on my blog contains screenshots and more detail.

[robg adds: I haven't tested this one.]
    •    
  • Currently 1.00 / 5
  You rated: 1 / 5 (9 votes cast)
 
[13,325 views]  

Automatically change the name of screenshot files | 12 comments | Create New Account
Click here to return to the 'Automatically change the name of screenshot files' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Automatically change the name of screenshot files
Authored by: N_Ox on Mar 27, '09 08:20:29AM

Wouldn't be easier to use the Folder Actions for this task?



[ Reply to This | # ]
Automatically change the name of screenshot files
Authored by: PancakeMan on Mar 27, '09 08:21:57AM
Quicksilver and its Screen Capture Actions plugin (see #4 here) would be another route to making screenshot workflow easier and more keyboard-friendly.

[ Reply to This | # ]
Automatically change the name of screenshot files
Authored by: mhayes on Mar 27, '09 08:31:55AM

You could also use the free app iStat.



[ Reply to This | # ]
Automatically change the name of screenshot files
Authored by: auco on Mar 27, '09 08:42:20AM

"Secrets" reveals some preference options for Grab:
com.apple.screencapture.type
com.apple.screencapture.path
com.apple.screencapture.name
com.apple.screencapture.disable-shadow



[ Reply to This | # ]
Another screenshot option
Authored by: KellanC on Mar 27, '09 09:50:46AM

I just use Skitch, a really great screenshot utility which is still in (free) open beta. Not only lets you retitle shots immediately after taking them, you can edit, annotate and archive them.



[ Reply to This | # ]
Automatically change the name of screenshot files
Authored by: vdubya on Mar 27, '09 11:24:03AM

You can also use "Hazel" or "Automator". With the Automator script you can easily have it rename and move the files automatically (with date and time), or allow you to change the file name on the fly.



[ Reply to This | # ]
Automatically change the name of screenshot files
Authored by: WetcoastBob on Mar 28, '09 10:29:17PM

You say: "One of my complaints when dealing with screenshots is that you cannot quickly select a screenshot with the keyboard. To do that, I need to navigate to the folder, hit Tab, then type in Picture, press the Space Bar, then type the number of the screenshot I want. "

I must be missing something here. Shift/command/3; Shift/command/4; shift/command/4/space. What else is there? if you do this, a file named Picture nn.png is the result and if you wish to change the name you can do so in the same manner that you change the name of any other file you display in finder.

---
Cheers:
Bob



[ Reply to This | # ]
The serious hints are here
Authored by: MJCube on Mar 29, '09 02:35:18PM

Seems odd that the tipster plugs his blog while withholding his name. I went to the site to see if I could find out anything about him, and of course that only has the effect of dinging his unique visitor count. Save a click: it looks like a site for tips about much more obvious things than here, with lots of pretty screencaps, and Google ads, but little content.



[ Reply to This | # ]
The serious hints are here
Authored by: palahala on Mar 29, '09 03:23:44PM

Hmmm, you've posted many much better comments than this!

Though I couldn't care less, I assume the tipster just forgot to log in when submitting the hint, or simply did not want to bother to sign up to share the tip. Many hints show "Anonymous" for the author, so following your conspiracy, all of those people would just have some hidden agenda to fool us into clicking a link?



[ Reply to This | # ]
The serious hints are here
Authored by: MacTipper on Mar 30, '09 07:05:00PM

My apologies about submitting it anonymously. For some reason, I thought I was logged in. :/

As far as plugging my website: it was Rob's call to keep it or not; he chose to keep it. Thanks Rob! :)

Also, I know that my tips are not as great as the tips on here. My target audience isn't the people who read MacOSXHints, it is new/non-power users of Mac. It's only the (rare) tips like this one that would interest power-users.

By the way, thanks for the ping to my visitor count. :)
--MacTipper



[ Reply to This | # ]
Automatically change the name of screenshot files
Authored by: neuro159 on Mar 29, '09 02:45:25PM

You can use ONYX tool to change prefix to be one letter i.e. 's' or whatever - its much easier to type! (goto parameters|general)

I suppose other twakers may also have some suitable options.



[ Reply to This | # ]
Automatically change the name of screenshot files
Authored by: amkim on Mar 24, '10 01:06:28PM

I have been so frustrated with Snow Leopard's new naming system for screen captures. Not only are the names extremely long, but they do not fall into chronological order if you have any number of them on your desktop and are viewing them in a list order, due to the date/time naming. This is extremely frustrating when trying to quickly mail out proof shots of a current project. I have to filter through my screen shots to find the correct one. Well, I have finally found a solution. Screenshot Plus 3.2 - I downloaded the widget here: http://www.apple.com/downloads/dashboard/business/screenshotplus.html

Now whenever I want to take a screenshot, I simply hit my dashboard short cut key and select which type of screenshot I would like (Full Screen, Full Window, Timed, or Custom Drag with Crosshairs) from the Screenshot Plus Widget and it automatically saves not only to where I want to save it to, but most importantly, with the custom name I select and in a chronological order! No more screen shot headaches :) Hope this helps ~ enjoy!



[ Reply to This | # ]