Possible duplicate: http://stackoverflow.com/questions/2548835/renaming-and-moving-files-in-bash-or-perl/2548919#2548919
I'm kinda newbie to perl and looking for a script that will handle file moving.
#!/usr/bin/perl -w
$filename = 'DUMBFILE';
$destination = '/some/location/';
if (-e $destination + $filename) {
print "File Exists ! Renaming ..";
move ('/tmp/' + $filename, $destination + $filename + '.1');
} else {
move ('/tmp/' + $filename, $destination + $filename);
}
I'm able to rename it to 1, but i want to be renamed incrementally, like if file.1 exists, rename to .2, and .3 if .2 exists.
EDIT : and keep the extension the same; like file.exe becomes file.exe.1, file.exe.2 etc.