Hi!
I have a list called files that contains:
/data/pau00/XX_PARADISE/lmk/xx_fl3d/dipaz.bri
/data/pau00/XX_PARADISE/lmk/xx_fl3d/dipaz.bri.meta
/data/pau00/XX_PARADISE/lmk/xx_fl3d/dipaz.bri.scaleFactor
What I want is to create a function that will replace the string a given string the each element of the list with a new string
for instance
old_name = dipaz
new_name = test
to get
/data/pau00/XX_PARADISE/lmk/xx_fl3d/test.bri
/data/pau00/XX_PARADISE/lmk/xx_fl3d/test.bri.meta
/data/pau00/XX_PARADISE/lmk/xx_fl3d/test.bri.scaleFactor
I have started doing something like this but I get no string replacement:
foreach item $files {
# replace item with new name
set new_item [string map {$old_name $new_name} $item]
puts "Old: $item New: $new_item"
}
In addition, it could be that the old string (dipaz here) exists in the file path as well and I don't want to replace it there..
Many thanks
I have a list called files that contains:
/data/pau00/XX_PARADISE/lmk/xx_fl3d/dipaz.bri
/data/pau00/XX_PARADISE/lmk/xx_fl3d/dipaz.bri.meta
/data/pau00/XX_PARADISE/lmk/xx_fl3d/dipaz.bri.scaleFactor
What I want is to create a function that will replace the string a given string the each element of the list with a new string
for instance
old_name = dipaz
new_name = test
to get
/data/pau00/XX_PARADISE/lmk/xx_fl3d/test.bri
/data/pau00/XX_PARADISE/lmk/xx_fl3d/test.bri.meta
/data/pau00/XX_PARADISE/lmk/xx_fl3d/test.bri.scaleFactor
I have started doing something like this but I get no string replacement:
foreach item $files {
# replace item with new name
set new_item [string map {$old_name $new_name} $item]
puts "Old: $item New: $new_item"
}
In addition, it could be that the old string (dipaz here) exists in the file path as well and I don't want to replace it there..
Many thanks