이 예에서는 여러 폴더의 DWG 파일을 한 번에 내보내는 방법을 보여줍니다. 여기에서는 오류 탐지 및 로그 기능이 있는 향상된 배치 파일이 사용됩니다.
배치 파일은 실행될 때마다 다음과 같은 매개변수 3개를 받습니다.
이전 예의 경우, 각각의 DWG에는 해당 내보내기 프로파일이 있어야 합니다. 이 예에서는 해당 프로파일이나 기본 프로파일 하나를 사용할 수 있습니다. DWG 파일에 각각의 고유한 프로파일이 없을 경우 기본 프로파일이 사용됩니다.
로그 파일은 각 DWG 파일에 대한 명령 윈도우 전체를 캡처합니다. 로그 파일에는 명령 윈도우 사용 내역을 시스템 클립보드로 옮기는 AutoCAD 명령인 copyhist가 사용됩니다. 이 예에서는 클립보드의 내용을 로그 파일에 붙여 넣기 위해 무료 오픈 소스 도구 winclip.exe가 사용됩니다.
하위 배치 파일에 대한 호출만 포함된 마스터 배치 파일로서 매개변수를 제공하는 "외부" 배치 파일에서 배치 파일을 호출할 수 있습니다.
예를 들어 세 도시에 대한 도면을 사용하는 경우, 배치 작업으로 한 도시의 도면 폴더를 내보내면 외부 배치 파일에 다음이 포함될 수 있습니다.
batchexport Redding\DWGs Redding\SDFs Redding\DefExport.epf batchexport Spokane\DWGs Spokane\SDFs Spokane\DefExport.epf batchexport Dubuque\DWGs Dubuque\SDFs Dubuque\DefExport.epf
이 방법을 사용하려면 각 호출마다 다른 export.log를 지정하거나 if exist export.log del export.log 행을 외부 배치 파일로 옮깁니다. 그렇지 않으면 호출될 때마다 이전 로그를 덮어쓰게 됩니다.
다음의 샘플 제작 배치 파일을 batchexport.bat라고 합니다. 이전 과정에서 수행한 것처럼 이 배치 파일을 메모장에 작성합니다.
@echo off setlocal rem Get and verify the command parameters set srcDir=%1 set outDir=%2 set defEpf=%3 if '%srcDir%' == '' goto usage if '%outDir%' == '' goto usage if '%defEpf%' == '' goto usage if not exist %srcDir% ( echo Source Directory "%srcDir%" not found. goto done ) if not exist %srcDir%\*.dwg ( echo No DWG files found in "%srcDir%". goto done ) if not exist %outDir% ( echo Destination Directory "%outDir%" not found. goto done ) if not exist %defEpf% (echo Default Export Profile "%defEpf%" not found. goto done ) if exist export.log del export.log rem Loop through the DWGs, exporting each for %%f in (%srcDir%\*.dwg) do ( if exist %outDir%\%%~nf.sdf del %outDir%\%%~nf.sdf echo. >> export.log echo ******* EXPORTING %%f TO %outDir%\%%~nf.sdf ******* >> export.log echo ******* EXPORTING %%f TO %outDir%\%%~nf.sdf ******* rem Create the Export Script ... echo _-mapexport> export.scr echo FDO_SDF>> export.scr echo %outDir%\%%~nf.sdf>> export.scr echo _yes>> export.scr if exist %%~df%%~pf%%~nf.epf ( rem Use a profile that has the same name as the DWG echo %%~df%%~pf%%~nf.epf>> export.scr ) else ( rem Use the default profile echo %defEpf%>> export.scr ) echo _proceed>> export.scr echo _copyhist>> export.scr echo _quit>> export.scr "C:\Program Files\AutoCAD Map 3D 2009\acad.exe" %%f /nologo /b export.scr winclip -p >> export.log ) goto done :usage echo USAGE: %0 [sourceDir] [destDir] [defaultExportProfile] echo example: %0 Redding\dwgs Redding\sdfs Redding\defExport.epf :done
오류 탐지 및 로그 기능이 있는 향상된 배치 파일을 작성하여 여러 폴더에 있는 DWG 파일을 한 번에 내보냈습니다.