• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 314
  • Last Modified:

Renaming several files at once

I would like to append a .org extension to some files in a directory,
e.g. renaming all files ending with .cc to .cc.org
Now, how can I do that without having to do a :
mv xxx.cc xxx.cc.org  on every file ?
also:
How substitute xxx.cc with xxx.org ?
Im seeking a command+arguments or a minor sh script..
0
moonlight
Asked:
moonlight
  • 4
  • 3
1 Solution
 
moonlightAuthor Commented:
Edited text of question
0
 
rayray120497Commented:
try this:

foreach i ( `ls *.cc` )
mv $i $i.org
end

0
 
rayray120497Commented:

also try this:

foreach i (`ls *.cc` )
set j = `expr $i : '\(.*\).cc'`
mv $i $j
end

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
rayray120497Commented:

sorry, should be

mv $i $j.org
0
 
moonlightAuthor Commented:
The first batch didnt work, somehow just one file gets renamed,
but the second did what I wanted, thanx!!
0
 
moonlightAuthor Commented:
First one works too now..excellent, thanks again rayray
0
 
ozoCommented:
 foreach i ( `ls *.cc` )
could be just
  foreach i ( *.cc )

but that's actually a csh command.  
in sh, it would be
  for i in `ls *.cc` ; do
     mv $i $i.org
  done
0
 
moonlightAuthor Commented:
thx, ozo.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now