Created
December 31, 2016 20:46
-
-
Save jaka/8b5882d75772b6a289690d7fc62fbc38 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# kicad2dp: Renames the Gerber files generated by KiCad to meet | |
# the naming convention required by DirtyPCBs.com PCB service. | |
# | |
# Usage: kicad2dp project_name | |
# project_name is the substring common to the all generated Gerber files. | |
# | |
# Note: This script works only for two layer PCBs, but could be easily | |
# extended for 4-layer boards. | |
# | |
# jaka, 2016 | |
RED="\033[1;31m" | |
GREEN="\033[1;32m" | |
NEUTRAL="\033[0m" | |
which zip >/dev/null || { | |
echo "${RED}Missing zip binary!$NEUTRAL" >&2 | |
exit 1 | |
} | |
[ -z "$1" ] && { | |
echo `basename $0` project_name >&2 | |
exit 1 | |
} | |
ORG_FILES="-F.Cu.gbr -B.Cu.gbr -F.Mask.gbr -B.Mask.gbr -F.SilkS.gbr -B.SilkS.gbr -Edge.Cuts.gbr .drl" | |
DST_FILES=".GTL .GBL .GTS .GBS .GTO .GBO .GKO .TXT" | |
DESCRIPTIONS="TOP COPPER LAYER\tBOTTOM COPPER LAYER\tTOP SOLDERMASK LAYER\tBOTTOM SOLDERMASK LAYER\tTOP SILKSCREEN LAYER\tBOTTOM SILKSCREEN LAYER\tBOARD OUTLINE\tNC DRILL" | |
_descs="$DESCRIPTIONS" | |
_dst_files="$DST_FILES" | |
_zip_files= | |
for _org_file in $ORG_FILES; do | |
_dst_file="${_dst_files%% *}" | |
_dst_files="${_dst_files#* }" | |
_desc="${_descs%%\\t*}" | |
_descs="${_descs#*\\t}" | |
if [ -w "$1$_org_file" ]; then | |
mv "$1$_org_file" "$1$_dst_file" | |
echo "$GREEN$_desc: $1$_org_file -> $1$_dst_file$NEUTRAL" | |
_zip_files="${_zip_files:+$_zip_files }$1$_dst_file" | |
else | |
echo "$RED$_desc NOT FOUND!$NEUTRAL" | |
fi | |
done | |
echo | |
if [ -n "$_zip_files" ]; then | |
echo "CREATING ARCHIVE $1.zip:" | |
zip -6 "$1".zip $_zip_files | |
echo "${GREEN}DONE!$NEUTRAL" | |
else | |
echo "${RED}NO FILES FOUND, ARCHIVE NOT CREATED$NEUTRAL" >&2 | |
exit 2 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment