LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-21-2006, 10:24 PM   #1
cranium2004
Member
 
Registered: Feb 2004
Distribution: FC4,RHEL4
Posts: 223

Rep: Reputation: 30
script to rename muliple files


helloo,
I downloaded some files using wget and i got thier names starting with "index.php?dir=" how can i remove them in one single script?
 
Old 02-21-2006, 10:29 PM   #2
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
There's the rename command with a syntax like rename from to file. An example from the man page is rename .htm .html *.htm. You'd probably have something like:
Code:
rename 'index.php?dir=' '' *
 
Old 02-21-2006, 10:46 PM   #3
cranium2004
Member
 
Registered: Feb 2004
Distribution: FC4,RHEL4
Posts: 223

Original Poster
Rep: Reputation: 30
hi,
no it not worked. see what i want is
if filename starts with index.php?dir=abcd?=&pqrxbook1.pdf then i want that file to be renames to book1.pdf only
 
Old 02-21-2006, 10:59 PM   #4
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
Did you try it this way?
Code:
$ ls -l
total 0
-rw-r--r--  1 steve steve 0 2006-02-22 14:54 index.php?dir=abcd?=&pqrxbook1.pdf
$ rename 'index.php?dir=abcd?=&pqrx' '' *
$ ls -l
total 0
-rw-r--r--  1 steve steve 0 2006-02-22 14:54 book1.pdf
Can the file names vary with different extensions or do the parameter values change?
 
  


Reply



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
Help with Bash Script - Rename Multiple Files embsupafly Programming 16 04-02-2010 03:50 AM
Batch Script to rename files... jamie_barrow Linux - Newbie 16 06-14-2009 01:26 PM
rename script all files in dir Longinus Linux - Newbie 8 08-02-2004 12:24 AM
Need script to rename files joe_stevensen Programming 5 12-05-2003 06:12 PM
Got a script to rename a batch of files? jamie_barrow Linux - General 1 08-08-2003 06:52 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:20 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration