Home > Blockchain >  Multiple file renaming based on regex pattern renaming within files based on new file names
Multiple file renaming based on regex pattern renaming within files based on new file names

Time:11-30

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:

  • Related