Reputation: 218
I have some files named as below:
e2ed150l145l245St01-Oxs_MinDriver-Magnetization-00-0002105.omf
e2ed150l145l250St01-Oxs_MinDriver-Magnetization-00-0002167.omf
e2ed150l145l255St01-Oxs_MinDriver-Magnetization-00-0001519.omf
e2ed150l145l260St01-Oxs_MinDriver-Magnetization-00-0001841.omf
e2ed150l145l265St01-Oxs_MinDriver-Magnetization-00-0002730.omf
e2ed150l145l270St01-Oxs_MinDriver-Magnetization-00-0002788.omf
e2ed150l145l275St01-Oxs_MinDriver-Magnetization-00-0001616.omf
e2ed150l150l250St01-Oxs_MinDriver-Magnetization-00-0002386.omf
e2ed150l150l2100St01-Oxs_MinDriver-Magnetization-00-0015577.omf
I want to rename them to:
e2ed150l145l245St01.omf
e2ed150l145l250St01.omf
e2ed150l145l255St01.omf
e2ed150l145l260St01.omf
e2ed150l145l265St01.omf
e2ed150l145l270St01.omf
e2ed150l145l275St01.omf
e2ed150l150l250St01.omf
e2ed150l150l2100St01.omf
Following some of the similar forums I used several commands including:
rename 's/-Oxs_MinDriver-Magnetization-00-[0-9]*//g' e2e*.omf -v
But it did not work. Please advise.
Upvotes: 0
Views: 94
Reputation: 84561
You can also use mv
as well:
for i in e2e*.omf; do
mv $i ${i%%-*}.omf
done
or
for i in e2e*.omf; do
mv $i ${i//-*/}.omf
done
To collapse to a single line:
for i in e2e*.omf; do mv $i ${i%%-*}.omf; done
If the destination already exists use mv -f
Upvotes: 1