Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2002-05-29
3
Medium Priority
?
162 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 84

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

DFW AZURE MEETUP TONIGHT FRI 6PM

We will be discussing what Azure Stack is, how does it fit into the suit of offerings that Azure has currently, and where can it fit into your organizations technology stack. We will also be discussing limitations of the platform while covering various applicable scenarios.

Question has a verified solution.

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

In this tutorial I will focus on how to use WhizBase as a tool for sending ICQ messages to ICQ. Here I will use a new technology in WhizBase, published in WhizBase 5.1 version. In this tutorial I will use 3 files, pager.wbsp for the processing, e…
It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

715 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