How to achieve this? I have a folder with over 1000 code files, mostly xml. Most of the files have a common pattern: abbb accc addd
a should be placed by z: zbbb zccc zddd
However, there are also files that do not start with a: efff ghhh
These names should then simply be preceded by z. zefff zghhh
Within the files various of the file names can show up. Hence, all original file names should be replaced by the new names within the files, too. My idea was something like putting original names in column 1 of a table and put the new names in column 2 next to them. Then looping over this table and if an original name is found within a file - it can also show up multiple times in code lines - and replace it with the new name. Any tips?
CodePudding user response:
This solved it for me:
- File renaming e.g. as described here: https://superuser.com/questions/16007/how-can-i-mass-rename-files
- Batch replacement with this VS Code plugin: https://marketplace.visualstudio.com/items?itemName=angelomollame.batch-replacer
- since I had the said table (old vs. new name) prepared, a simple regex replacement of the table entries did the trick to meet the prerequisites for the plugin, i. e. the old names were replaced by replace "old_file_name" and the new names by with "new_file_name"; then, just copy & paste everything for this plugin as described there and all is replaced