Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Simple renaming problem....help...ASAP !!!!

Posted on 2002-05-29
3
Medium Priority
?
164 Views
Last Modified: 2013-12-25
Hi !

I have a folder containg files in order ..i.e. 1.pl, 2.pl , 3.pl , 4.pl , 5.pl and so on...

the folder also contains other files...now what i want is that when i delete 3.pl and 1.pl , i should be able to run a script which renames 2.pl as 1.pl 4.pl as 2.pl and 5.pl as 3.pl ... this is just an example.. i should be able to delete any files and then run the script inorder to make them 1,2,3,4,5 and so on..... i hope u understand what it means...

please help asap...
thanks in advance
0
Comment
Question by:anant99
3 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7043780
ls [0-9]*.pl|sed 's/\.pl//'|sort|awk '{print "mv "$0".pl "++x".pl"}'|sh
0
 

Expert Comment

by:glewis
ID: 7210310
Obviously, you didn't like the Unix/Linux command-line (shell) option.  What language would you like it in?  Perl?  Ruby?
-- Glenn
0
 
LVL 85

Accepted Solution

by:
ozo earned 900 total points
ID: 7210749
perl -e 'rename$_,++$x.".pl"for sort{$a<=>$b}<[0-9]*.pl>'
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses

876 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