Solved

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

Posted on 2002-05-29
3
155 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 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Introduction:   Welcome to my first article ever. To begin with, the reason I write this article.  I participated in a question on Experts Exchange about the start command in Windows and there were some discussion about the usage. The discussio…
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
The viewer will learn how to dynamically set the form action using jQuery.

679 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