InDesign tip : #06

keyboard shortcuts activate commands without the need to access a panel or menu. if you take the time to learn even just a few you will increase your productivity — freeing up more time for creativity or whatever else you prefer to do with your valuable time. so, this post is going to be about keyboard shortcuts, but you’re not going to be given a list of maybe-helpful shortcuts. why? because, firstly, there’s already a plethora of shortcut lists out there — google is your friend — secondly, because lists do not help you find the shortcuts that YOU need for your working situation.

instead, this post is about how to find the so-called ‘hidden’ (you haven’t looked for) and ‘little-known’ (others haven’t looked for either) keyboard shortcuts. more importantly, it is also about how to create your own set of shortcuts for your most often used commands.

the first way to find a shortcut, as you probably already know, is to look at the command in the appropriate menu. below is the dropdown for the edit menu showing that the keyboard shortcut for ‘cut’ is cmd-x :
screen grab of edit menu

the way to find all the other shortcuts is also in the edit menu — it’s called, funnily enough, keyboard shortcuts. this is how you find the shortcut for ‘cut’ in the edit menu (this is CS2, other versions look similar) :
screen grab of keyboard shortcuts window

flicking through all the different product areas you’ll see there are literally hundreds of commands. the easiest way to search for ‘hidden’ shortcuts however is to hit the ‘show set’ button. this will open a searchable text file in your default text editor. scroll down past all the ‘menu’ listings and you’ll get to the good stuff :
screen grab showing keyboard shortcuts in text editor

you’ll see that many many commands simply do not have a shortcut — [none defined] — but you don’t have to accept the status quo. you can create your own ‘set’ of shortcuts for commands you use on a regular basis. whatever you want. you can even create shortcuts to activate your scripts :
screen grab showing how to assign a new shortcut

to add a new shortcut, find the command you want to target, click in the ‘new shortcut’ field and hit your shortcut (that is, for example, hold down cmd and x, don’t try to type “Cmd+X”). if you try to add a shortcut that is already assigned to another command, you’ll be warned (as shown above). you can choose to go ahead anyway — your new shortcut will override the previous one — or you may choose to reassign your new shortcut to a key combination that is still available :
screen grab showing reassigned shortcut

once you start setting up shortcuts appropriate to your own workflow, you’ll never look back. if you have a brain the size of a planet you could assign a shortcut to every possible command and never have to use a menu or panel again. go sick.

macgrunt icon

Advertisements

renaming finder items II

renaming finder items introduced a couple of ways to batch-rename files in the finder using either automator or applescript, depending on the complexity of the job. those examples involved altering the existing filename by replacing characters or removing parts of the name. here’s another renaming workflow that was developed when one set of filenames needed to be mapped to a completely different set — hundreds of barcodes named by ISBN needed to be renamed by product code.

Applescript Icon applescript is fantastic for this kind of work because renaming hundreds of files by hand is just about as tedious as it gets. as with most scripting tasks, there are myriad ways this problem could be tackled — here’s just one :

screen grab showing filenames in excel

this solution starts with two lists — original filenames and new filenames — in a single excel worksheet. for this version of the app to work correctly, the worksheet needs to be saved in the same folder as the files to be changed and the worksheet needs to be open in excel.

the app looks through the top level of the folder for files and folders matching the names in column A and changes the filenames to the corresponding ones in column B — simple. files that don’t match a name in the list are skipped. all original file extensions are maintained. files in subfolders remain untouched. here’s a before and after shot of test files :

screen grab showing files before and after name changes

RenameByList is a zipped folder containing the app and a sample excel file. to use it — update the excel spreadsheet to your requirements, put all your files in the same folder and double-click the app :

you can get a copy of RenameByList here

screen grab showing compiled script in script editor

for those interested in this sort of thing…
excel can be a bit of a pain to script. for example, this is the command to extract the entries in column A :
set mgANames to formula of range mgARange

instead of giving us a list of names :

{"9781234567890", "9781234567891", "9781234567892" ...

this command gives us a list of lists :

{{"9781234567890"}, {"9781234567891"}, {"9781234567892"} ...

that’s why we need to loop through the original list (mgANames) with this command — to convert the list of lists into a straight list :
set end of mgOriginalNames to item 1 of item x of mgANames

the other way would be to just loop through the cells in excel to make the list in one pass like this :

tell used range to set mgRowCount to count rows
repeat with x from 2 to mgRowCount
  set end of mgOriginalNames to formula of cell ("A" & x)
  set end of mgNewNames to formula of cell ("B" & x)
end repeat

but this script was developed and tested through script editor before being saved out as an app. and this second method is MUCH slower through script editor (although not much different when run as an app). try it yourself.


• related post : renaming finder items : renaming using automator or applescript.
• related post : renaming finder items III : renaming by creation date.

macgrunt icon

InDesign scripting : lesson 05

let’s revisit a couple of the elements of the script from lesson 04 so you have a better understanding of how they work and how you can integrate them into other scripts. here’s the script again :

Screen grab of Print All Files script

the first thing we’re asking the script to do is place the names of all of InDesign’s current printer presets into a variable which we’ve called mgPresetList. having studied lesson 03 you’ll know that the variable can be called anything you like, as long as it doesn’t clash with standard applescript terminology. mgPresetList is a list of names being generated by InDesign every time the script is run. if printer presets are added or deleted in InDesign, the list will change next time the script is run.

in applescript a list looks like this : {“[Default]”, “A4 landscape”, “A4 portrait”, “A4 landscape (spreads)”, “A3 landscape”, “A3 portrait”, “A3 landscape (spreads)”, “A4 no crops”}. curly braces delineate the start and end of the list, and the elements of the list are contained within double-quotes and separated by commas. if it suited the workflow, we could restrict the list to just the A3 landscape presets by ‘hard-coding’ the list :

set mgPresetList to {"A3 landscape", "A3 landscape (spreads)"}

ok, that’s a quick introduction to lists. we’ll look at other things you can do with lists in future lessons.

next — the choose from list command. this command is an example of a user interface — a way for the script to interact with the user (you) during the running of the script. sometimes user interfaces get input from the user, as in this case. sometimes they merely communicate with the user, as in the display dialog command at the end of the script.

the last part of the choose from list command was explained in lesson 04. let’s look at the first part. the most fundamental example of this command takes the form :

choose from list {SomeList}

our script could have skipped placing the printer preset list into a separate variable like this :

choose from list (name of every printer preset as list)

this is mostly a matter of style. placing data into variables is a good way to keep track of things when you’re starting out. please yourself.

speaking of variables, this is where our second variable comes into play :

set mgPrintPreset to choose from list ...

the mgPrintPreset variable will contain the result of the choose from list command. there are other ways to capture the result of this command, but “set [VariableName] to …” is the easiest.

in the next lesson we’ll look at another important aspect of this script — error handling. so many important elements packed into one simple little script aren’t there?

meanwhile — check out the difference to the second user interface if you delete the second half of the command and just write :

display dialog "ALL DONE!"

macgrunt icon

video 03 : relinking images

macgrunt is all about workflow optimisation, with an emphasis on automation, particularly applescript. you’d be truly amazed at how much time can be saved in a studio by simply automating mundane tasks. not only does it free up more time for creativity, it also saves you from banging your head repeatedly against your desk due to the sheer tedium of some of the work you have to do — every day.

this script was created for a publishing workflow where images in archived InDesign files were no longer linked to the overhauled library of over 100,000 images. at reprint time, these images had to be relinked — sometimes in their hundreds.

relinking images is a quick animation which shows an actual script performing a real-life task in a fraction of the time it would take a real-life human. the animation is built from screen grabs from the actual workflow — so that dialog box showing how long the script took to do its job is real and accurate (testing was done with CS2 on a G5 PowerPC running OSX 10.5.7).

if that doesn’t convince you to start learning, stay tuned, more to follow (perhaps).

macgrunt icon

InDesign tip : #05

before launching into the latest tip — here’s a funny little story… imagine someone, a friend, is interested in automating workflows and uses applescript to achieve quite astonishing time savings. this friend regularly deals with old dodgy files which no longer behave correctly and has to rebuild them by copying all the content across to a new, fresh file (inx and idml are no good because most links are broken at this stage of the workflow). no worries, applescript should be able to handle the problem easily. and it DOES. our friend is chuffed because he needs to use this script about five or six times a year to recover failing files. got all that? cool.

now imagine this friend discovering that InDesign can already copy all the content from one file into another. the function is already there — no scripting required — works perfectly. talk about laugh.

ok, so the story is not THAT funny, unless you’re a geek (because they don’t get out much). anyway, here’s the tip…

salvage a recalcitrant file — duplicate its contents to a fresh file :
create a new file with the same dimensions as the original
the new file only needs a single page
go to your original file and select every page in the pages panel
from the pages panel dropdown menu, choose ‘move pages…’
select your new document from the ‘Move to:’ dropdown menu
delete the first page from the new document and save
bonza!

pages panel dropdown screen grab
move pages window screen grab

unfortunately this functionality is not available in CS2 — not sure about CS3 — definitely works in CS4 and later.

postscript
in fairness to our friend, it should be mentioned that the original script was written for CS2 — when the ‘move pages’ command did not support inter-document transfers. you’ll be pleased to know that the script is still useful.
a modified version was used just this week, apparently, to copy the contents of only two layers of a 55 page file across to four other existing files which needed the same content added to the same pages.

if you are interested in having a play with the original script…
you can get a copy of DupDoc.applescript here

macgrunt icon