1

I've designated a folder to receive screen shots I receive from the default Mac screenshot command. How can I elicit a prompt that will let me rename every screenshot I take?

Thank you

  • 1
    Welcome to Ask Different! Kindly edit the question to share the relevant details as to how you designated the folder and which screenshot command you are referring to. If you followed an article, please share its link. Providing relevant details will help in getting suitable answer quickly. – Nimesh Neema May 2 '18 at 21:36
3

I used Cocktail to specify that screenshots are saved to a folder called "Screenshots" on my Mac. I use an app called "Hazel" to watch that folder and to automatically run an AppleScript that shows a dialog box asking if I want to rename the screenshot.

Here is the dialog box that pops up automatically:

Dialog box asking whether I'd like to rename a screenshot

Here is a screenshot of Hazel, with my "Name it" rule: Hazel screenshot

Clicking the edit (pencil) button in that window shows you the conditions under which the rule will run. As you can see, Hazel will run the AppleScript if the file is an image, added today, whose comment does NOT contain the word "Hazel." Since newly-made screenshots do not have comments with the word "Hazel" in them, these are the right conditions. (When the script runs, it adds a comment with the word "Hazel" in it to the file.) Hazel rule conditions

Here is my AppleScript.

tell application "System Events"
    set the_apps to every process whose frontmost is true
    set the_app to item 1 of the_apps
    set the_app_name to name of the_app
    set old_name to name of theFile
    set the_choice to display dialog "If you want to rename this file, do it" buttons {"Rename", "No thanks"} default button "Rename" default answer old_name
end tell

if the button returned of the_choice is "Rename" then
    set the_date_string to do shell script "date '+%Y.%m.%d'"
    tell application "Finder"
        set the comment of theFile to "Name changed with Hazel"
        set the_name to text returned of the_choice
        set cleaned_name to change " " into "_" in the_name
        set cleaned_name to the_date_string & "_" & cleaned_name
        if (characters 12 thru 13 of cleaned_name as string) is "wm" then
            move theFile to (POSIX file "/Users/cboyce/Dropbox/Screenshots/Webmaster Screenshots")
        else
            move theFile to (POSIX file "/Users/cboyce/Dropbox/Screenshots/Renamed Screenshots")
        end if
        set the name of theFile to cleaned_name & ".png"
    end tell
end if
tell application the_app_name to activate

The first part of the script records the name of the frontmost app at the time of the screenshot's creation. It also has the "Display Dialog" step.

The second part of the script renames the screenshot and moves it to a "Renamed Screenshots" folder. If I put "wm" at the beginning of the file's new name, the script puts the renamed screenshot into a special "Webmaster Screenshots" folder. The script also replaces spaces with underscores, but you would not have to include that part. Notice also that the script sets the comment of the screenshot to "Name changed with Hazel." You of course can make your own conditions but this works for me.

You will have to change the username in the script, in the two lines that start with "move theFile." Replace "cboyce" (my username) with whatever yours is. If you're not sure what yours is, find the Users folder at the top level of your Mac's hard drive, open that up, and look for the folder with the house icon. The name of that folder is the username. Actually, you have to change the entire path. I'm saving my renamed screenshots into folders stored in my Dropbox folder but you of course can put them where you like. So change the path in those "move theFile" lines to point to YOUR folders.

Hazel is commercial software but you can use it in Demo mode for free. Demo mode allows you to watch only a single folder, which in your case is all you need. You can download Hazel from Noodlesoft.com.

  • Hello spazek's solution worked for me, with it asking for the filename before the screenshot is taken. Thanks for the help! I am sure this question will help those with newer Mac versions. – K Tran May 3 '18 at 19:07
2

You might try using the app Grab. It comes with your system software and is stored in the Utilities folder. You can use Grab to take a screenshot, then click on menu item File and choose Save. This will allow you to name the file and select folder to store screen shot.

  • Hello, spazek's solution worked for me. Thanks for the suggestion! – K Tran May 3 '18 at 19:06
0

You might create a Service with Automator.app, to which you can assign a shortcut in the Services Preferences (even existing ones can be overwritten).

Open Automator, select Service as the type of document, select in the upper part of the window: Service receives no input in any application. Double-click action Run AppleScript or drag it into the right half of the window and insert the following script:

set destFolder to "/Path/to/the/Folder/" --insert here path to Screenshot folder

set screenshotName to text returned of (display dialog "Screenshot" default answer "")
set destFile to destFolder & screenshotName & ".png"

---------------------------------------
-- give a warning in case file is already existing
try
alias (POSIX file destFile)
set _exists to true
repeat until _exists is false
try
set screenshotName to text returned of (display dialog "Filename is already existing!" default answer "")
alias (POSIX file (destFolder & screenshotName & ".png"))
on error
set _exists to false
    end try
end repeat
set destFile to destFolder & screenshotName & ".png"
end try

---------------------------------------------

do shell script "screencapture -io " & quoted form of destFile

(*
--------------------------
screencapture:
-i = Capture screen interactively
-o = In window capture mode, do not capture the shadow of the window
--------------------------
*)

Be sure to insert the path to your screenshot folder in the first line!

The script does not rename ... but first sets the name and then creates the screenshot.

To access the "Services Preferences" quickly, click on the name of the currently active program in the menu bar (e.g. Safari) and select "Services Preferences" in the "Services" menu item. Find your created Service there and add a shortcut to it ... e.g. cmd-ctrl-5

  • This worked beautifully! Thank you so much :) I was having issues with previously answered SA questions as it seems the apple syntax changed. Cheers! – K Tran May 3 '18 at 19:05

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.