Hi,
I have names of all files in output.txt
but I do not have folderpath
in output.txt
file. For Example, if filename = test.txt
and its folderpath=/usr/local/bin
than in output.txt
file, I only have filename as test.txt
output.txt
files has many entries for filename
, what I am trying to do is:
Move all files present
output.txt
to some another folder say '/usr/local/test/data/', so my question is how can I do that usingPerl Script
?Delete all the files which are present in
output.txt
file from the actual location, using theirfolderpath
, so for example, script should first movetest.txt
to some other folder location, say,/usr/local/test/data/test.txt
and delete test.txt from its actual location using folderpath information, i.e., script should delete/usr/local/bin/test.txt
Any suggestions would be highly appreciated.
Updates: Below scripts reads the output.txt file and gets size of each file and total size of all the files present in the output.txt
my $folderpath = 'the_path';
open my $IN, '<', 'path/to/infile';
my $total;
while (<$IN>) {
chomp;
my $size = -s "$folderpath/$_";
print "$_ => $size\n";
$total += $size;
}
print "Total => $total\n";
Output.txt
2304_2328_Test Data November 19 2003 - Test Tele.xls
2344_2341_Data Dummy Test 12-17.doc
2343_2342_Dummy Test Test 12-17.doc
My output.txt file also have some files whose name contain special characters, for example,
63551_106640_63551 IBMý
;Software Delivery&Fulfillment(Div-61) Data IPS 08-20-2010 v3.xlsm
If you see above the file has encoded value of ý
but my filename has actual special character symbol for that and so will copy or move take my this file also into account and move the files.