Solved

Renaming several files at once

Posted on 1998-06-24
8
306 Views
Last Modified: 2011-08-18
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
Comment
Question by:moonlight
  • 4
  • 3
8 Comments
 
LVL 3

Author Comment

by:moonlight
ID: 2008247
Edited text of question
0
 

Accepted Solution

by:
rayray120497 earned 0 total points
ID: 2008248
try this:

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

0
 

Expert Comment

by:rayray120497
ID: 2008249

also try this:

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

0
 

Expert Comment

by:rayray120497
ID: 2008250

sorry, should be

mv $i $j.org
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 3

Author Comment

by:moonlight
ID: 2008251
The first batch didnt work, somehow just one file gets renamed,
but the second did what I wanted, thanx!!
0
 
LVL 3

Author Comment

by:moonlight
ID: 2008252
First one works too now..excellent, thanks again rayray
0
 
LVL 84

Expert Comment

by:ozo
ID: 2008253
 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
 
LVL 3

Author Comment

by:moonlight
ID: 2008254
thx, ozo.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now