cancel
Showing results for 
Search instead for 
Did you mean: 

TCL Reculsive Search for Sub Directories - CSE Post

PLM World Member Pioneer PLM World Member Pioneer
PLM World Member Pioneer

Hello All,

 

Good Morning!

 

We have been trying to search files in sub directories from a main folder using glob in the below format.

 

set dir "C:\/Users\/xxxxx\/Desktop\/NC\/"

cd $dir

set curdir [pwd]

while {[llength $dir]} {

     set name [lindex $dir 0]

     set dir [concat [lrange $dir 1 end] [

    glob -nocomplain -directory [lindex $dir 0] -type d *]]

MOM_output_text "DIR: $name" }

 

However, it always throws error!!!

 

Error Info: bad switch "-directory": must be -nocomplain or -- while executing "glob -nocomplain -directory [lindex $dir 0] -type d *"

 

Kindly let me know if I am missing any syntax here. 

 

Thanks,

Jithesh

 

 

10 REPLIES

Re: TCL Reculsive Search for Sub Directories - CSE Post

Pioneer
Pioneer

The attached program does exactly what you are looking for.

Re: TCL Reculsive Search for Sub Directories - CSE Post

PLM World Member Pioneer PLM World Member Pioneer
PLM World Member Pioneer
Hi pmoss,
Thanks for your support.
I understand the logic in your code.
However, the NX postbuilder does not accept this format.

I even tried converting all the procs to individual custom commands (PB_CMD_xxxxx) and calling them in the required sequence from the main proc. Still no luck!

glob -nocomplain -directory and normalize are giving syntax error!

Regards,
Jithesh

Re: TCL Reculsive Search for Sub Directories - CSE Post

Pioneer
Pioneer

Attached is code that works with UGwish. I tested it.

 

If you use the logic from my first set of code, and combine it with the attached code, you'll be able to glob whatever you WISH (lol) while posting.

 

UGwish is an old version of TCL

 

 

Re: TCL Reculsive Search for Sub Directories - CSE Post

Pioneer
Pioneer

 

Also ...

 

You can test TCL code outside of posting or PB by manually activating the UGwish shell.

 

Run the executable found in your UGII_BASE_DIR\MACH\auxillary\ugwish.exe

 

and drop your code in there.

 

Re: TCL Reculsive Search for Sub Directories - CSE Post

Esteemed Contributor
Esteemed Contributor

Note that the tcl used directly during posting is an "older" version (hence some commands/options not supported) and stripped down (e.g. no TK).  So in some cases, you will need to call the external ugwish to do some things.

Ken Akerboom Sr CAx Systems Engr, Moog, Inc.
Production: NX10.0.3.5 MP5 + patch/TC11.2
I'd rather be e-steemed than e-diseaseled


Re: TCL Reculsive Search for Sub Directories - CSE Post

PLM World Member Pioneer PLM World Member Pioneer
PLM World Member Pioneer

Hello Pmoss and Ken,

 

Thank You very much for your valuable suggestions.

 

Currently I am trying the method as you suggested.

 

Will keep you posted on the updages

 

Regards,

Jithesh.

Re: TCL Reculsive Search for Sub Directories - CSE Post

PLM World Member Pioneer PLM World Member Pioneer
PLM World Member Pioneer

Hello Pmoss and Ken,

 

I have been trying to run your code in ugwish. Could not succeed.

So I tried a simple code, (attached here with) below by using File > Source. However nothing happens.

 

We use NX/Postbuilder Version: 7.5.5.1, and the Tcl Version is Tcl 8.2.2.

 

Also, I was wondering how to call external ugwish directly from PB and execute code during postprocessing. 

 

 

Regards,

Jithesh

Re: TCL Reculsive Search for Sub Directories - CSE Post

Pioneer
Pioneer

2014-07-28 09_15_53-Reply to Message - Siemens PLM Community.png

Re: TCL Reculsive Search for Sub Directories - CSE Post

Pioneer
Pioneer

I posted with the above code and got the directories and contents that I was looking for in my network user folder.

 

Massage the code a little to perform recursion you need.

 

 

Learn online





Solution Information