i have some files in a folder with names like abc_old.php now i want to rename them as abc.php that is i want to remove that "_old" from all of my file names.How can i do this in one go ????
Write a program that loops round, parses the filename, makes the changes you want and renames the file. I'm not aware of any shortcut way of doing this.
You'll probably find it easier to cop the files to your local machine, run the program to make the name changes there, and then upload the newly named files back to the FTP server (and obviously delete the old ones)
Shell facilities are going to be limited via FTP. I would copy the files across to a local directory. In bash (given that in the above you claim to have Linux available):
for filename in *_old.php
do
mv $filename ${filename%_old.php}.php
done
The % operator matches the end of the string and returns $filename without the matched segment (the bit after the %). Hence the above chops the _old.php and then substitutes a .php.
I have not tested the above. Try it on a dummy directory first.
A long time ago, I found a small snippet of code in the back of the Programming Perl 4 O'Reilly book that let you rename files using regular expressions. I have used that ever since. Being able to use Perl regular expressions, especially tr and s, has made file renaming so easy. So cut this out, paste it into a file called rename on your path, make it executable "chmod ugo+x rename" and keep it as part of your regular arsenal of tools. Check where your perl is with "which perl" and adjust the first line appropriately. This assumes you're on a Unix system with access to Perl.
#!/usr/bin/perl
# Usage: rename perlexpr [files]
($op = shift) || die "Usage: rename perlexpr [filenames]\n";
if (!@ARGV)
{
@ARGV = <STDIN>;
chop (@ARGV);
}
for (@ARGV)
{
$was = $_;
eval $op;
die $@ if $@;
rename ($was,$_) unless $was eq $_;
}
So for your example, you could do
rename "s/_old//" *_old.php
Oops. The tag for this question is ftp. If your access is via ftp, then this is not going to work, because you are not going to have shell access.