Renaming files by removing suffix

This is just a reminder to myself how to rename files by removing a suffix. The typical scenario is that I have just renamed a bunch of files, by adding the suffix .bak or something like that. Now I want to rename the files to their original name by removing .bak.

For example to rename all files matching *.conf.bak so that just have the .conf-suffix: 

for i in $(ls *.conf.bak); do mv -f $i ${i%.conf.bak}.conf; done;

 

 

 



 

Comments

Post new comment

  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd><pre>
  • Lines and paragraphs break automatically.

More information about formatting options

To combat spam, please enter the code in the image.