Showing results for 
Search instead for 
Did you mean: 

Assemblies: Batch script to distinguish between components/sub-assemblies/assemblies from parts in a directory

Community Manager Community Manager
Community Manager

 Many times user needs to find components/sub-assemblies/assemblies from bulk parts in a directory. So using existing "ugpc” utility and below batch script, now more consolidated report in .csv file format is generated. This script also loops through all parts in sub-directories.


Steps to run batch script:

  1. Create a file with .bat extension and copy-paste below text and save it.
    @Echo off
    echo "Part name along with path","Part Name","Conponent count" >> Output.csv
    set /p id="Specify directory to scan: "
    (For /R %id%\ %%G IN (*.prt
        ) do For /f %%A in ('ugpc %%G ^|C:\Windows\System32\find.exe /i /c ".prt"') Do Echo(%%G,%%~nxG,%%A
    ) >> Output.csv
  1. Launch NX cmd (command prompt).
  2. Drag-drop above file in cmd and hit enter button.
  3. It will ask directory to be scanned for part files. Specify it in cmd and hit enter.
  4. csv in below format will be created at the end of script run. Apply filter to last column to find desired parts.

Batch Script cvc.png

Solution Partner Legend Solution Partner Legend
Solution Partner Legend

Remember to cd to another work directory first as the output.csv file will be placed in this folder.



Siemens Phenom Siemens Phenom
Siemens Phenom

Or just add some path before file Output.csv to create it at desired location.