Note that there are some explanatory texts on larger screens.

plurals
  1. POPerl File Handling question?
    primarykey
    data
    text
    <p>I have names of all files in <code>output.txt</code> but I do not have <code>folderpath</code> in <code>output.txt</code> file. For Example, if <code>filename = test.txt</code> and its <code>folderpath=/usr/local/bin</code> than in <code>output.txt</code> file, I only have <code>filename as test.txt</code></p> <p><code>output.txt</code> files has many entries for <code>filename</code>, what I am trying to do is:</p> <ol> <li><p>Move all files present <code>output.txt</code> to some another folder say '/usr/local/test/data/', so my question is how can I do that using <code>Perl Script</code> ?</p></li> <li><p>Delete all the files which are present in <code>output.txt</code> file from the actual location, using their <code>folderpath</code>, so for example, script should first move <code>test.txt</code> to some other folder location, say, <code>/usr/local/test/data/test.txt</code> and delete test.txt from its actual location using folderpath information, i.e., script should delete <code>/usr/local/bin/test.txt</code></p></li> </ol> <p>Any suggestions would be highly appreciated. </p> <p><strong>Updates:</strong> 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</p> <pre><code>my $folderpath = 'the_path'; open my $IN, '&lt;', 'path/to/infile'; my $total; while (&lt;$IN&gt;) { chomp; my $size = -s "$folderpath/$_"; print "$_ =&gt; $size\n"; $total += $size; } print "Total =&gt; $total\n"; </code></pre> <p>Courtesy: <a href="https://stackoverflow.com/users/447771/rickf">RickF</a> <a href="https://stackoverflow.com/questions/3746552/file-manipulation-scripting-question/3753986#3753986">Answer</a></p> <p><strong>Output.txt</strong> </p> <pre><code>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 </code></pre> <p>My output.txt file also have some files whose name contain special characters, for example, 63551_106640_63551 IBM<code>&amp;#253</code>;Software Delivery&amp;Fulfillment(Div-61) Data IPS 08-20-2010 v3.xlsm</p> <p>If you see above the file has encoded value of <code>&amp;#253</code> 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. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload