User Tools

Site Tools


scripts:perl:restore-all-deleted-dfs.pl
restore-all-deleted-dfs.pl
#!/usr/bin/perl
 
# use module
use XML::Simple;
use Data::Dumper;
use File::Basename;
use File::Path qw(make_path remove_tree);
use File::Copy;
 
# create object
$xml = new XML::Simple;
 
# read XML file
$data = $xml->XMLin("ConflictAndDeletedManifest.xml");
 
# print output
#print Dumper($data);
 
foreach $e (@{$data->{Resource}})
{
	my $modfile;
 
	# Parse out unneeded junk from path
	if ($e->{Path} =~ m/^.*Quality\\(.*)$/) {
		$modfile = $1;
	}
 
	# Parse path from file name
	my ($tmpfilename, $tmpdirectories, $tmpsuffix) = fileparse($modfile);
 
	# Get the newname from DFS
	my $newname = $e->{NewName};
 
	# Make the directory structure
	#make_path($tmpdirectories);
 
	# Copy files
	copy("ConflictAndDeleted\\" . $newname, $tmpdirectories . "\\" . $tmpfilename);
 
	# Debug
	print $modfile . "\n" . $tmpdirectories . "\n" . $tmpfilename . "\n";
}
/var/www/vhost/www.fuhell.com/data/pages/scripts/perl/restore-all-deleted-dfs.pl.txt · Last modified: 2014/09/01 15:00 (external edit)