Exercise 1: Extend the Batch File Capabilities

The following example shows how to amend the batch file you created in Creating a Simple Batch File. In this example, you specify the location of the DWG files and the location of the exported files. The batch file creates a script for each DWG file. It uses a profile with the same name as the DWG file.

For example, Dubuque.dwg would have to have a corresponding Dubuque.epf. So, to use this method, create an EPF for each DWG.

To create the complex batch file

  1. In Notepad, enter the following:
    set srcDir=D:\Redding\DWGs
    set outDir=D:\ReddingSDFs
    

    Substitute the directories shown with your own directories. Specify the directories where you store the drawing files and the exported files.

  2. Create the temporary export script temp.scr by entering the following lines.
    for %%f in (%srcDir%\*.dwg) do (
    echo _-mapexport>          temp.scr
    echo FDO_SDF>>             temp.scr
    echo %outDir%\%%~nf.sdf>>  temp.scr
    echo _yes>>                  temp.scr
    
  3. Create an export profile with the same base name as the drawing file.
    echo %%~df%%~pf%%~nf.epf>> temp.scr
    echo _proceed>>                  temp.scr
    echo _quit>>               temp.scr
    "C:\Program Files\AutoCAD Map 3D 2021\acad.exe" %%f /b temp.scr
    )
    

    Substitute the location of your installed application, if needed.

  4. Name and save the batch file.
    Note:

    Run the batch file from the Command window. You can also use the DOS "AT" command to set up a schedule to run the batch file automatically at specific times.

Where you are now

You refined the batch file you created in Creating a Simple Batch File. The file now specifies the location of the DWG files and the location of the exported files.

To continue this tutorial, go to Creating a Production Batch File.