Solved

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

Posted on 2002-05-29
3
159 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 300 total points
ID: 7210749
perl -e 'rename$_,++$x.".pl"for sort{$a<=>$b}<[0-9]*.pl>'
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to pick specific file from ftp 13 76
Powershell GUI 11 95
debug scriptblock parameters in powershell script 2 48
form isn't working is it missing a document 21 64
Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
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…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
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)

738 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