Copy and Rename multiple files in Linux

How you can go about copying and renaming files in Linux

I am pasting this here for my own reference!

for i in `ls files-to-copy-*`; do cp $i `echo $i | sed "s/rename-from/rename-to/g"`; done

What this does is takes each file that is returned of the result of your ls command and pipes it do sed.

This sed command then looks for the part you want to rename and does it (“s/rename-from/rename-to/g” is a regular expression).


Recent posts View all

Ruby

Forcing a Rails database column to be not null

How you can force a table column to always have something in it with Rails

Writing Marketing

We've deleted an article's worth of unhelpful words

We've improved several pages across our site by removing words that add no value, and often detract from the article.