Hardware Reference
In-Depth Information
Note: The third line of this script makes use of the backtick (`) character, which is
called a grave accent when placed over a vowel. It's on the same key as the tilde (~),
and should not be confused with the apostrophe (') or the backslash ( \ ).
To run this script, enter ./br.sh followed by the old extension, the new extension, and the
folder in which to make the change—in that order. For example, to change all the files in
~/Documents with the extension .JPG to end in .jpeg , enter this:
./br.sh JPG jpeg ~/Documents
Tip: To learn more about shell scripting, read Apple's Shell Scripting Primer .
Shell Scripts Outside the Shell
But wait! Isn't renaming documents the sort of thing you might want to do frequently,
without having to mess around in Terminal? Absolutely. So that's the sort of script that you
might want to put in a launcher (like LaunchBar), a text-expansion tool (like TextExpander),
or a macro utility (like Keyboard Maestro), so that you can execute it with just a keystroke or
click.
The problem with this particular example script is that it doesn't run on its own; it asks for
three arguments (or parameters)—namely, the “before” extension, the “after” extension, and
the folder in which to change the files. So, without modifications, it wouldn't work embedded
in another tool.
There are many ways to work around this problem, and I'll show you one example later, in
Control Your Mac with Keyboard Maestro .
Search WWH ::




Custom Search