Reputation: 1748
I am new in perl script. I want to write perl which delete previous backup file and extract new backup file from dropbox and rename with specific file name.
Example:
backup location:
D:\Database\store_name\
containing .bak
files
Actual folder data
D:\Database\Mahavir Dhanya Bhandar\
contain .bak
file
D:\Database\Patel General Store\
containg .bak
files
..so on
*.bak
files store_recursively
2.extract new backup file from dropbox and rename with specific file name.Upvotes: 1
Views: 868
Reputation: 6057
Have you looked into walking your file tree. http://rosettacode.org/wiki/Walk_a_directory/Recursively. Combine this with simple file operations (copying, deleting, etc.) and you should be good.
use File::Find qw(find);
my $dir = "D:\Database\Store_Name";
find sub {unlink $File::Find::name if /\.bak$/}, $dir;
and assuming that connectToDropbox()
connects to your dropbox
use File::Copy;
use File::Find qw(find);
my $backup = connectToDropbox();
my $dir = "D\Database\Store_Name";
find sub {copy($backup -> getFile("file"), "newFile")} $dir;
of course, this assumes that you already can set up a connection and such to Dropbox. If not, there is a good CPAN libraryhere you can check out.
Upvotes: 1