Hardware Reference
In-Depth Information
▪
Prompt:
This macro renames all selected files
that have the "From" extension to have the "To"
extension (e.g., JPG -> jpeg).
▪
Variables and Default Values:
Click plus and then fill in
From
for the first variable name,
JPG
for its value; click plus
again and fill in
To
for the second variable name and
jpeg
for its
value. (Leave the remaining settings as is.)
5. Click Control Flow in the Categories list and add For Each as the second action.
In the For Each field, enter
filePath
. Click plus and then choose The
Finder's Selection Collection from the pop-up menu. (Leave the Fix Finder
Selection Bug option checked.)
6. Click Execute in the Categories list and drag Execute a Shell Script to the No
Action field (under “execute the following actions”). (In other words, you're
embedding one action inside another.)
7. In the Execute Shell Script action, make sure the first pop-up menu says
Execute Text Script. Then type or paste the following into the text field
exactly
as shown here (including spaces):
base=`basename "$KMVAR_filePath" .$KMVAR_From`
ext="${KMVAR_filePath##*.}"
path=`dirname "$KMVAR_filePath"`
if [ $ext == $KMVAR_From ]
then
mv "$KMVAR_filePath" "$path/$base.$KMVAR_To"
fi
You'll notice a few passing similarities to the shell script back in
Script the
Command Line with Shell Scripts
, but also quite a few differences.
8. Double-check to see that the macro looks like
Figure 45
.