I'm using a folder action and a little Perl script. That will rename the original screen shot's file name to something more handy and it will create a 2nd version with the reduced resolution. My setup is that I have a ~/Pictures/Screenshots
where the files end up.
Here are the steps to set it up. Of course you have to create the above folder. Then create a .plist file with a contents like
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>some.domain.renamescreenshots</string>
<key>ProgramArguments</key>
<array>
<string>/Users/you/Library/LaunchAgents/rename-screenshots.sh</string>
</array>
<key>WatchPaths</key>
<array>
<string>/Users/you/Desktop</string>
</array>
</dict>
</plist>
where the you
needs to be your user name. And save this as /Users/you/Library/LaunchAgents/some.domain.renamescreenshots.plist
Note the WatchPaths
parameter which specifies where the OS will watch for changes. Here the screen shots end up per default.
In the same folder you create a Perl script like
#! /usr/bin/perl
for my $f (</Users/you/Desktop/Bil*>) {
if ($f =~/Bil.*(\d{4})-(\d{2})-(\d{2}) um (\d{2})\.(\d{2})\.(\d{2})\.png/) {
$dest = "/Users/you/Pictures/Screenshots/pic$1$2$3$4$5$6";
$res = `file "$f"`;
$res =~ /.* (\d+) x (\d+),.*/;
$half = $1/2;
`mv "$f" $dest.png`;
`/usr/bin/sips -Z $half $dest.png -o $dest.2.png`;
}
}
which is doing the actual conversion and save it as /Users/you/Library/LaunchAgents/rename-screenshots.sh
(like specified in the .plist). Note that again you
must be replaced. Also the source /Users/you/Desktop/Bil*
must be adjusted. Since it's German they start with Bil
(and some more text including a YYYY-MM-DD date format plus the time after the word "um" meaning at). That will be different per country so the path/regex must be adjusted. The destination file name is then formatted as picYYMMDDHHMMSS.png
. Finally the sips
will create a reduced copy of that file with a "2"-suffix for the name.
To actually start the whole stuff you need to register the service via
launchctl load /Users/you/Library/LaunchAgents/some.domain.renamescreenshots.plist
That will trigger the script when a screen shot is taken. (unload will unregister the service if you don't need it any more.)
Note The above is likely to cause several pain when installing. I regularly forget how and where to set it up. And the .sh
is nonsense as it should be .pl
but that's history too. It just works. Orignally (up to this answer) I had the script only for renaming the screen shot. But I got annoyed by the bloated screen shots that I needed for StackOverflow. So I found this sips
here and included it.