Shell Scripts to Export Multiple Mockups
Hi there, I just wrote a shell script (in OS X) that goes through the current directory and all of its children and exports any bmml file it finds to png, placing the png next to the original bmml file.
Here's the script:
#!/bin/bash
mockupsApp="/Volumes/Macintosh HD/Applications/Balsamiq Mockups.app/Contents/MacOS/Balsamiq Mockups";
cdir=`pwd`;
for f in `find . -name "*.bmml" | awk '{gsub(/ /,"%20");print}'`;
do
infile=`echo ${cdir}/${f} | awk '{gsub(/%20/, "\ ");print}'`;
outfile=`echo $infile | awk '{sub(/bmml/,"png");print}'`;
echo "Converting $infile to $outfile";
`"$mockupsApp" export "$infile" "$outfile"`;
done
I wanted to post it here so that if someone who's better at shell scripting than me wanted to improve it, we'd have a place to do it. Also, if you have created similar scripts for Win or Linux and are willing to share, paste them here!
Thanks,
Peldi
Here's the script:
#!/bin/bash
mockupsApp="/Volumes/Macintosh HD/Applications/Balsamiq Mockups.app/Contents/MacOS/Balsamiq Mockups";
cdir=`pwd`;
for f in `find . -name "*.bmml" | awk '{gsub(/ /,"%20");print}'`;
do
infile=`echo ${cdir}/${f} | awk '{gsub(/%20/, "\ ");print}'`;
outfile=`echo $infile | awk '{sub(/bmml/,"png");print}'`;
echo "Converting $infile to $outfile";
`"$mockupsApp" export "$infile" "$outfile"`;
done
I wanted to post it here so that if someone who's better at shell scripting than me wanted to improve it, we'd have a place to do it. Also, if you have created similar scripts for Win or Linux and are willing to share, paste them here!
Thanks,
Peldi
Follow this discussion to get notifications on your dashboard.
-
Inappropriate?Just so anybody who uses it knows, you must exit any running instance of Mockups before you run the script or it won't work.
Thanks for this, Peldi, it is a very happy feature and script!
I’m giddy.
-
Inappropriate?For those stuck with Wintel, here's a DOS script that will perform recursive PNG exports. If run without a parameter, it will progress down from the current directory and park the PNGs wherever the BMML files are found. If a directory parameter is supplied (and found to exist), the exports are sent there. (Some folks prefer to keep source and output segregated.)
@echo off
if not [%1]==[] goto :pth
for /r %%G in (*.bmml) do (
echo %%~dpG%%~nG.png
"C:\Program Files\Balsamiq Mockups\Balsamiq Mockups.exe" export "%%~fG" "%%~dpG%%~nG.png"
)
exit /b
:pth
if exist %1 (
for /r %%G in (*.bmml) do (
echo %~f1\%%~nG.png
"C:\Program Files\Balsamiq Mockups\Balsamiq Mockups.exe" export "%%~fG" "%~f1\%%~nG.png"
)
) else (
echo Export directory "%~f1" does not exist.
)
I’m kickin' it old school tonight.
-
Michael you are a wizard, and a very generous one too! Thanks so much for sharing this! -
Inappropriate?Genius I tell you!
-
Inappropriate?Very helpful! It is a bit slow in Windows as the app loads repeatedly, but a heck of a lot better than doing it manually.
-
Inappropriate?Peldi,
following you script for Mac, i got error:
2009-02-06 09:32:33.295 Balsamiq Mockups[5326:10b] NSDocumentController Info.plist warning: The values of CFBundleTypeRole entries must be 'Editor', 'Viewer', 'None', or 'Shell'.
I’m thankful
-
Hi Su, that's just a warning, you can safely ignore it. Did the export work? -
Inappropriate?I ignore the warnings but could not get the script to export.
-
Hi Jeff, what OS are you on? Which script are you testing?
Loading Profile...







