LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Closed Thread
 
Search this Thread
Old 10-11-2003, 01:22 AM   #1
oopicmaster
Member
 
Registered: Sep 2003
Posts: 154

Rep: Reputation: 30
2 Thumbs Up for Windows!


Why?

Because Ive spent the last half hour trying to do something in Linux that would be SIMPLE to do in Windows.

Whats that you ask?

Rename a bunch of files.

The Windows command would be simple:

ren GPO*.h CX*.h

In Windows this would rename all of the files that start with GPO, and end with .h to files that start with CX and end with .h

Simple...

To do this in Linux I guess Ill need to write code?

There HAS to be a better way.
 
Old 10-11-2003, 01:37 AM   #2
wuck
Member
 
Registered: Sep 2003
Location: barneveld.nl
Distribution: Slackware
Posts: 170

Rep: Reputation: 30
One word: mv

$ mv GPO*.h CX*.h

You could've done a seach on some online man pages website or an apropos about 'moving files'
 
Old 10-11-2003, 01:46 AM   #3
megaspaz
Senior Member
 
Registered: Nov 2002
Location: Silly Con Valley
Distribution: Red Hat 7.3, Red Hat 9.0
Posts: 2,054

Rep: Reputation: 46
to expand upon what wuck said. not only was there google or the forums' search, but you could've asked here too before posting like a schmuck. you may have gotten a few RTFM responses or use the forum search responses, but someone would have given you the command that wuck gave you.
 
Old 10-11-2003, 01:53 AM   #4
arunshivanandan
Member
 
Registered: May 2003
Location: Kerala,India
Distribution: RedHat,Mandrake,Debian
Posts: 643

Rep: Reputation: 30
i think there is 'rename' command in linux.i have never used it though.check the man page for more info.(man rename)
 
Old 10-11-2003, 02:16 AM   #5
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,111

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
Quote:
Originally posted by megaspaz
to expand upon what wuck said. not only was there google or the forums' search, but you could've asked here too before posting like a schmuck. you may have gotten a few RTFM responses or use the forum search responses, but someone would have given you the command that wuck gave you.
yup megaspaz is right, posts like yours are the digital equivelant of throughing rocks at a bee hive, you will make the bees angry and most probably get stung serveral times

Last edited by frieza; 10-11-2003 at 02:17 AM.
 
Old 10-11-2003, 02:33 AM   #6
oopicmaster
Member
 
Registered: Sep 2003
Posts: 154

Original Poster
Rep: Reputation: 30
Uh....Hmmmm....

mv GPO*.h CX*.h doesnt work...

Maybe I can get a response from someone who knows about Linux?

Anyone? Is there a Linux expert in the house?
 
Old 10-11-2003, 02:36 AM   #7
megaspaz
Senior Member
 
Registered: Nov 2002
Location: Silly Con Valley
Distribution: Red Hat 7.3, Red Hat 9.0
Posts: 2,054

Rep: Reputation: 46
what kind of output are you getting? any error messages? are you in a directory that you have write permissions for? are you in that directory? more info needed. and try a "man rename"
 
Old 10-11-2003, 02:39 AM   #8
oopicmaster
Member
 
Registered: Sep 2003
Posts: 154

Original Poster
Rep: Reputation: 30
rename doesnt work either... it gives no output whatsoever

mv GPO*.h CX*.h gives the following output:

mv: when moving multiple files, the last argument must be a directory.
 
Old 10-11-2003, 02:41 AM   #9
arunshivanandan
Member
 
Registered: May 2003
Location: Kerala,India
Distribution: RedHat,Mandrake,Debian
Posts: 643

Rep: Reputation: 30
Wow,you want torvalds or alen cox to come and explain to you the 'mv' and 'rename' command??
-------------
try 'rename <What_You_Want_to_Convert> <to> <file_name>
ie,
Code:
rename GPO CX GPO*.h
-------------------------------
--arun
 
Old 10-11-2003, 02:44 AM   #10
arunshivanandan
Member
 
Registered: May 2003
Location: Kerala,India
Distribution: RedHat,Mandrake,Debian
Posts: 643

Rep: Reputation: 30
and ofcourse,mv abc*.h vsdh*.h wont work.(obviously).mv is move(similar to cp).and you think * will be replaced with what??so you can move multiple files into a directory.(again obvious,.)
and it was easy in dos (to use 'ren') cos you knew that command.now that you know 'rename' you will find it easy.though it is sure that windows is much more userfriendly,it cannot be compared to your case.(rename is a fine tool.you couldnt rename cos you didnt knew abt 'rename'.the same thing applies to windows.)

Last edited by arunshivanandan; 10-11-2003 at 02:53 AM.
 
Old 10-11-2003, 02:51 AM   #11
oopicmaster
Member
 
Registered: Sep 2003
Posts: 154

Original Poster
Rep: Reputation: 30
Well I think its a big problem with the mv command. If you can move one file to another it should do multiples. Same with cp, I shouldnt be forced to move or copy multiples to a directory.

Like I said, if it can be done in Windows.... sigh.
 
Old 10-11-2003, 02:55 AM   #12
arunshivanandan
Member
 
Registered: May 2003
Location: Kerala,India
Distribution: RedHat,Mandrake,Debian
Posts: 643

Rep: Reputation: 30
Did 'rename GPO CX GPO*.h' work for you??
 
Old 10-11-2003, 02:59 AM   #13
Col Panic
Member
 
Registered: Oct 2003
Distribution: Red Hat 9
Posts: 93

Rep: Reputation: 15
Change file extensions

for f in myfile.+([0-9])*
do
print mv $f ${f%*.}.new
done


Change all but extensions

for f in myfile.+([0-9])*
do
print mv $f newfile.${f##*.}
done


do it in a ksh shell.

OR
http://linux.maruhn.com/sec/ren.html
download, configure, install and use the ren command if you do this alot

Last edited by Col Panic; 10-11-2003 at 03:02 AM.
 
Old 10-11-2003, 02:59 AM   #14
oopicmaster
Member
 
Registered: Sep 2003
Posts: 154

Original Poster
Rep: Reputation: 30
When I try it, Ill let you know...
 
Old 10-11-2003, 03:02 AM   #15
arunshivanandan
Member
 
Registered: May 2003
Location: Kerala,India
Distribution: RedHat,Mandrake,Debian
Posts: 643

Rep: Reputation: 30
i dont know why you guys make such a fuss abt something so trivial..............
 
  


Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
March of the Penguins movie - Thumbs up! J.W. General 2 07-10-2005 08:04 PM
Thumbs Up To Linux! redfedora88 LinuxQuestions.org Member Success Stories 3 03-22-2005 08:35 PM
Thumbs up for Suse 9.1 Wolfgang67 Linux - Distributions 18 08-05-2004 09:30 PM
2 thumbs up for linux. xode LinuxQuestions.org Member Success Stories 2 11-23-2003 06:57 PM
winex - 5 thumbs up! kazuni LinuxQuestions.org Member Success Stories 8 06-05-2003 08:43 PM


All times are GMT -5. The time now is 09:58 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration