Running a command on multiple files using TCL script

558 views Asked by At

I am using a certain tool (Synopsys Design Vision) which I am running by using a TCL script.

The command is something like this

analyze -library work -format verilog {/user/codes/abcd.v }

Now I have a folder with 5000 .v extension files with names abcd_1, abcd_2, abcd_3.....abcd_5000. Now I want to automate the script so that the command works on each and very file.

I tried to do something like this

for { set a 1}  {$a < 5001} {incr a} {
analyze -library work -format verilog {/user/codes/abcd_$a.v }
#other commands
.
.
}

However, it is not working and giving error. I have not worked with tcl scripts that much.

Kindly specify where I am going wrong and what can I do to make it work. Thank you.

1

There are 1 answers

0
mrcalvin On BEST ANSWER

To cut it short, use quotes rather than braces, as the latter prevent variable substitution from happening:

for {set a 1}  {$a < 5001} {incr a} {
  analyze -library work -format verilog "/user/codes/abcd_$a.v"
  # ...
}

However, you might also want to check out the file command to assemble file paths.