- May 11, 2008
- 20,141
- 1,149
- 126
I made this handy dandy batch file with the help of a lot of googling.
It automates a lot of tasks that need to be done manually.
It asks for a filename for the zip file and how many layers.
Currently i has obly 2 ,4 or 6 layers options but that can be easily expanded.
It renames the gerber files to a format more easy readable.
It renames the files according to how we at work have our naming convetion for the layer stack.
After that, it copies the NC drill files to the gerber directory.
It then calls 7z.exe to archive everything into a zip file which has the name given by the user.
It automates a lot of tasks that need to be done manually.
It asks for a filename for the zip file and how many layers.
Currently i has obly 2 ,4 or 6 layers options but that can be easily expanded.
It renames the gerber files to a format more easy readable.
It renames the files according to how we at work have our naming convetion for the layer stack.
After that, it copies the NC drill files to the gerber directory.
It then calls 7z.exe to archive everything into a zip file which has the name given by the user.
Code:
:: Things to do when 7z.exe is not found by batchfile.
:: install 7zip compression /decompression utility 7zip.
:: copy 7z.exe to system32 folder of windows.
:: Done.
@ECHO OFF
:: Turn the below echo on to enable debug messages.
:: @ECHO ON
CLS
ECHO gerber rename and package utility by William. V1.00
set /p gerbername=Typ the desired output zipfile name and press Enter:
ECHO Select the amount of copper layers of the board and press Enter.
ECHO 2. 2 layer board.
ECHO 4. 4 layer board.
ECHO 6. 6 layer board.
ECHO.
set /p a=Type option:
IF %a%==6 GOTO 6layer_setup
IF %a%==4 GOTO 4layer_setup
IF %a%==2 GOTO 2layer_setup
GOTO End
:2layer_setup
ECHO 2 layer stack selected.
cd Gerber
FOR %%A IN (*.GTL) DO REN "%%~fA" "1_TOP1_%%~nA.*"
FOR %%A IN (*.GBL) DO REN "%%~fA" "2_BOT2_%%~nA.*"
FOR %%A IN (*.GBO) DO REN "%%~fA" "BOTTOM_SILKSCREEN_LEGEND_%%~nA.*"
FOR %%A IN (*.GTO) DO REN "%%~fA" "TOP_SILKSCREEN_LEGEND_%%~nA.*"
FOR %%A IN (*.GTS) DO REN "%%~fA" "TOP_SOLDERMASK_%%~nA.*"
FOR %%A IN (*.GBS) DO REN "%%~fA" "BOTTOM_SOLDERMASK_%%~nA.*"
cd..
GOTO End
:4layer_setup
ECHO 4 layer stack selected.
cd Gerber
FOR %%A IN (*.GTL) DO REN "%%~fA" "1_TOP1_%%~nA.*"
FOR %%A IN (*.G1) DO REN "%%~fA" "2_IN2_%%~nA.*"
FOR %%A IN (*.G2) DO REN "%%~fA" "3_IN3_%%~nA.*"
FOR %%A IN (*.GBL) DO REN "%%~fA" "4_BOT4_%%~nA.*"
FOR %%A IN (*.GBO) DO REN "%%~fA" "BOTTOM_SILKSCREEN_LEGEND_%%~nA.*"
FOR %%A IN (*.GTO) DO REN "%%~fA" "TOP_SILKSCREEN_LEGEND_%%~nA.*"
FOR %%A IN (*.GTS) DO REN "%%~fA" "TOP_SOLDERMASK_%%~nA.*"
FOR %%A IN (*.GBS) DO REN "%%~fA" "BOTTOM_SOLDERMASK_%%~nA.*"
cd..
GOTO End
:6layer_setup
ECHO 6 layer stack selected.
cd Gerber
FOR %%A IN (*.GTL) DO REN "%%~fA" "1_TOP1_%%~nA.*"
FOR %%A IN (*.G1) DO REN "%%~fA" "2_IN2_%%~nA.*"
FOR %%A IN (*.G2) DO REN "%%~fA" "3_IN3_%%~nA.*"
FOR %%A IN (*.G3) DO REN "%%~fA" "4_IN4_%%~nA.*"
FOR %%A IN (*.G4) DO REN "%%~fA" "5_IN5_%%~nA.*"
FOR %%A IN (*.GBL) DO REN "%%~fA" "6_BOT6_%%~nA.*"
FOR %%A IN (*.GBO) DO REN "%%~fA" "BOTTOM_SILKSCREEN_LEGEND_%%~nA.*"
FOR %%A IN (*.GTO) DO REN "%%~fA" "TOP_SILKSCREEN_LEGEND_%%~nA.*"
FOR %%A IN (*.GTS) DO REN "%%~fA" "TOP_SOLDERMASK_%%~nA.*"
FOR %%A IN (*.GBS) DO REN "%%~fA" "BOTTOM_SOLDERMASK_%%~nA.*"
cd..
:End
@ECHO ...
:: Display path
:: ECHO %0
set filepath=%~dp0
:: ECHO %filepath%
set sourcepath=%filepath%NC Drill
set destinationpath=%filepath%Gerber
ECHO sourcepath=%sourcepath%
ECHO destinationpath=%destinationpath%
@ECHO ...
xcopy "%sourcepath%" "%destinationpath%" /f /y
set zippath=%filepath%Gerber\*.*
set gerberzipfilename=%gerbername%.zip
::ECHO %gerbername%
@ECHO ...
ECHO filename=%gerberzipfilename%
ECHO source files path=%zippath%
@ECHO ...
7z a %gerberzipfilename% "%zippath%"
CHOICE /C Q /M "Press Q to quit"