Solved

Renaming several files at once

Posted on 1998-06-24
8
305 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
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.

708 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

16 Experts available now in Live!

Get 1:1 Help Now