#!/usr/bin/perl use strict; use warnings; # VARIABLES # Subscriptions Library & Archive Path variables for clarity my $Subscriptions_Path = '/mnt/hgfs'; # Subscription DATA sets my @Subscription = ( { Sub_Name => 'T 1', Lib_Sub_Path => 'VM-Share', Keep_Duration => 0, }, { Sub_Name => 'T 2', Lib_Sub_Path => 'VM-Share/xtr', Keep_Duration => 0, }, { Sub_Name => 'T 3', Lib_Sub_Path => 'VM-Share/xtr 2', Keep_Duration => 0, }, ); for my $curr_sub ( @Subscription ) { print "Beginning Subscription Service for $curr_sub->{Sub_Name}\n"; chdir "$Subscriptions_Path/$curr_sub->{Lib_Sub_Path}" or do { print "Could not find directory: $Subscriptions_Path/$curr_sub->{Lib_Sub_Path}\n"; next; }; opendir my $DH, '.' or die "Cannot open directory '$Subscriptions_Path/$curr_sub->{Lib_Sub_Path}' because: $!"; while ( my $file = readdir $DH ) { next unless -f $file; my $new = $file; $new =~ s/_/ /g; rename $file, $new or do { print "Could not rename '$file' because: $!"; next; }; } print "Completing Subscription Service for $curr_sub->{Sub_Name}\n\n"; }