I tried this ruby script and it works fine on klayout GUI, and we are trying to find out how to batch rename files in command terminal with Non-GUI mode, thanks for your kindly support~ :)
Follow this topic, is it possible to remove or change the prefix or suffix had been added in the cells with this rename function?
Ex, All cells in the layout have had the suffix "_20120923" to remark the last update time. I want to change the original suffix "_20120923" to "_20121023", if it is possible to use this rename function?
string = RBA::InputDialog.get_string("Specify rename expression", "Use '*' to refer to the original name, '#' to refer to the numeric cell ID.\nFor example, 'A*' will prepend the prefix 'A' to the cell name.", "*")
if !string.has_value?
return
end
...
new_cell_name = string.value.gsub(/#/, cell.cell_index.to_s).gsub(/\*/, cell_name)
to something like:
search = RBA::InputDialog.get_string("Specify original string", "Specify the string which shall be replaced", "")
if !search.has_value?
return
end
replace = RBA::InputDialog.get_string("Specify replacement string", "Specify the string which shall replace the original string", "")
if !replace.has_value?
search
end
...
new_cell_name = cell_name.gsub(search.value, replace.value)
Then you will be prompted for the original and replacement string. This function will replace all occurrences of the original string in all cell names with the replacement string.
Comments
Hi chhung,
It should be possible to create a Ruby script to do so. I'll try to provide such a script shortly.
Best regards,
Matthias
Hallo,
in the meantime I have uploaded a script to do that:
http://www.klayout.de/useful_scripts.html#rename_cells.rbm.
Best regards,
Matthias
I tried this ruby script and it works fine on klayout GUI, and we are trying to find out how to batch rename files in command terminal with Non-GUI mode, thanks for your kindly support~ :)
Best Regards,
--
chhung
Follow this topic, is it possible to remove or change the prefix or suffix had been added in the cells with this rename function?
Ex, All cells in the layout have had the suffix "_20120923" to remark the last update time. I want to change the original suffix "_20120923" to "_20121023", if it is possible to use this rename function?
Thank you.
Regards,
Canny
Hi Canny,
sure it is with some modification.
The trick is to modify the following lines:
to something like:
Then you will be prompted for the original and replacement string. This function will replace all occurrences of the original string in all cell names with the replacement string.
Best regards,
Matthias
Thank you, it is awesome.
Regards,
Canny