Toolpath renaming with specific String

rajesh.kanna
Autodesk

Toolpath renaming with specific String

rajesh.kanna
Autodesk
Autodesk

I need to change my toolpath name as given below

 

Original

1_01_00_Rough

1_01_00_Finish1

1_02_00_Finish3

1_02_00_Finish3

 

The output need is 

 

1_01_00_Rough

1_02_00_Finish1

1_03_00_Finish3

1_04_00_Finish3

 

See the macro below, only I can change "01" character only

 

INT Count = 00
FOREACH tp IN folder('Toolpath') {
ACTIVATE TOOLPATH $TP.Name
$Count = Count + 01
//STRING NewName = replace(tp.Name, '01', "0" +'$Count')
STRING NewName = Replace(tp.Name, "0" +'$Count', Start:=3)
RENAME TOOLPATH $tp.Name $NewName
}

0 Likes
Reply
Accepted solutions (1)
580 Views
2 Replies
Replies (2)

Anonymous
Not applicable
Accepted solution
INT Count = 0
FOREACH tp IN folder('Toolpath') {
   $Count = $Count + 1
   STRING CNT=string($Count)
   IF $Count<10 {
      $CNT='0'+$CNT
   }
   STRING LIST N=tokens($tp.Name,"_")
   STRING NewName = $N[0]+"_"+$CNT
   INT J=2
   WHILE $J < size($N) {
      $NewName=$NewName+'_'+$N[$J]
      $J=$J+1
   }
   RENAME TOOLPATH $tp.Name $NewName
}

rajesh.kanna
Autodesk
Autodesk

Thank you very much

0 Likes