<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: extract similar kind of files through perl script in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/extract-similar-kind-of-files-through-perl-script/m-p/3817608#M100246</link>
    <description>Not perl, but it may help you.&lt;BR /&gt;&lt;BR /&gt;find . -depth \( -name "*.jpg" -o -name "*.gif" -o -name "*.bmp" \) -exec ll -d {} \; &amp;gt; grap.txt&lt;BR /&gt;[ -f grap.txt ] &amp;amp;&amp;amp; mkdir grap&lt;BR /&gt;cat grap.txt | while read line&lt;BR /&gt;do&lt;BR /&gt;mv ${line} grap/.&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Same for other types of files.</description>
    <pubDate>Wed, 05 Jul 2006 07:01:48 GMT</pubDate>
    <dc:creator>RAC_1</dc:creator>
    <dc:date>2006-07-05T07:01:48Z</dc:date>
    <item>
      <title>extract similar kind of files through perl script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/extract-similar-kind-of-files-through-perl-script/m-p/3817606#M100244</link>
      <description>Hi...&lt;BR /&gt; &lt;BR /&gt;I need extract files and put them in respective folders depending on a config file.&lt;BR /&gt;&lt;BR /&gt;That is...the config file is as below&lt;BR /&gt;grap=*.jpg,*.gif,*.bmp&lt;BR /&gt;backup=*.~*,*.tmp,*.bak&lt;BR /&gt;Source=*.pl,*.php,*.tcl&lt;BR /&gt;&lt;BR /&gt;depending on this the script should scan all the files &amp;amp; subdirectories in an user given directory and create a directory in the name specified in the config file i.e created dir name is as before(leftside) of = in config file and the files scaned and that should be put in that directory is those files with the extension after = .&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 05 Jul 2006 06:48:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/extract-similar-kind-of-files-through-perl-script/m-p/3817606#M100244</guid>
      <dc:creator>Sasirekha</dc:creator>
      <dc:date>2006-07-05T06:48:08Z</dc:date>
    </item>
    <item>
      <title>Re: extract similar kind of files through perl script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/extract-similar-kind-of-files-through-perl-script/m-p/3817607#M100245</link>
      <description>&lt;!--!*#--&gt;--8&amp;lt;--- untested braindump follows ...&lt;BR /&gt;#!/opt/perl/bin/perl&lt;BR /&gt;&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;&lt;BR /&gt;use Cwd;&lt;BR /&gt;use File::Find;&lt;BR /&gt;use File::Copy;&lt;BR /&gt;&lt;BR /&gt;my $config_file = shift;&lt;BR /&gt;-f $config_file &amp;amp;&amp;amp; -s _ &amp;amp;&amp;amp; -r _ or die "$config_file: not a (valid/readable) config file\n";&lt;BR /&gt;&lt;BR /&gt;my $pwd = getcwd;&lt;BR /&gt;my %config;&lt;BR /&gt;{   @ARGV = ($config_file);&lt;BR /&gt;    while (&amp;lt;&amp;gt;) {&lt;BR /&gt;        m/^[;#]/ and next; # Comment&lt;BR /&gt;        my ($dir, $pat) = m/^\s*(\S+)\s*=\s*(.*)/ or next;&lt;BR /&gt;        $config{$dir} = [ split m/\s*[,;]\s*/, $pat ];&lt;BR /&gt;        }&lt;BR /&gt;    }&lt;BR /&gt;&lt;BR /&gt;foreach my $dir (keys %config) {&lt;BR /&gt;    -d $dir or mkdir $dir, 0777;&lt;BR /&gt;    }&lt;BR /&gt;&lt;BR /&gt;find {sub {&lt;BR /&gt;    (my $tld = $File::Find::dir) =~ s{^(?:\./)?([^/]+)(?:/.*}{};&lt;BR /&gt;    exists $config{$tld} and return;&lt;BR /&gt;    foreach my $dir (keys %config) {&lt;BR /&gt;        foreach my $file (map { glob $_ } @{$config{$dir}}) {&lt;BR /&gt;            copy $file, "$pwd/$dir";&lt;BR /&gt;            }&lt;BR /&gt;        }&lt;BR /&gt;    }, ".");&lt;BR /&gt;--&amp;gt;8---&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Wed, 05 Jul 2006 07:01:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/extract-similar-kind-of-files-through-perl-script/m-p/3817607#M100245</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2006-07-05T07:01:44Z</dc:date>
    </item>
    <item>
      <title>Re: extract similar kind of files through perl script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/extract-similar-kind-of-files-through-perl-script/m-p/3817608#M100246</link>
      <description>Not perl, but it may help you.&lt;BR /&gt;&lt;BR /&gt;find . -depth \( -name "*.jpg" -o -name "*.gif" -o -name "*.bmp" \) -exec ll -d {} \; &amp;gt; grap.txt&lt;BR /&gt;[ -f grap.txt ] &amp;amp;&amp;amp; mkdir grap&lt;BR /&gt;cat grap.txt | while read line&lt;BR /&gt;do&lt;BR /&gt;mv ${line} grap/.&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Same for other types of files.</description>
      <pubDate>Wed, 05 Jul 2006 07:01:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/extract-similar-kind-of-files-through-perl-script/m-p/3817608#M100246</guid>
      <dc:creator>RAC_1</dc:creator>
      <dc:date>2006-07-05T07:01:48Z</dc:date>
    </item>
    <item>
      <title>Re: extract similar kind of files through perl script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/extract-similar-kind-of-files-through-perl-script/m-p/3817609#M100247</link>
      <description>I won't provide a solution&lt;BR /&gt;(if you wait a little you probably get a rather thorough one from procura),&lt;BR /&gt;just a few hints.&lt;BR /&gt; &lt;BR /&gt;To recursively search directory trees import the Find::File module.&lt;BR /&gt;It merely reuires the definition of a small callback sub (mostly an anonymous one even suffices).&lt;BR /&gt;On the other hand you can use C-shell like filename globbing from Perl which the glob() function or the &amp;lt;&amp;gt; brackets provide &lt;BR /&gt;(though its use is generally deprecated).&lt;BR /&gt;Then there are opendir(), readdir(), and closedir().&lt;BR /&gt;To create new directories you could use the mkdir() function, and unlink() deletes files.&lt;BR /&gt;All are nicely documented in your installation's POD.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 05 Jul 2006 07:04:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/extract-similar-kind-of-files-through-perl-script/m-p/3817609#M100247</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2006-07-05T07:04:18Z</dc:date>
    </item>
    <item>
      <title>Re: extract similar kind of files through perl script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/extract-similar-kind-of-files-through-perl-script/m-p/3817610#M100248</link>
      <description>Sorry for my noise,&lt;BR /&gt;procura already submitted while I was still searching the keys on my keyboard.</description>
      <pubDate>Wed, 05 Jul 2006 07:06:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/extract-similar-kind-of-files-through-perl-script/m-p/3817610#M100248</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2006-07-05T07:06:46Z</dc:date>
    </item>
    <item>
      <title>Re: extract similar kind of files through perl script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/extract-similar-kind-of-files-through-perl-script/m-p/3817611#M100249</link>
      <description>Hi ...&lt;BR /&gt;&lt;BR /&gt;The code is not working I am getting the following error&lt;BR /&gt; &lt;BR /&gt;"Use of uninitialized value in -f at testfti line 14.&lt;BR /&gt;Use of uninitialized value in concatenation (.) or string at testfti line 14.&lt;BR /&gt;: not a (valid/readable) config file"&lt;BR /&gt;&lt;BR /&gt;&amp;amp; the folder "graph" is not created.once that &lt;BR /&gt;folder is created all the *.jpg,*.gif,*.bmp,etc files should get copied into that folder.</description>
      <pubDate>Thu, 06 Jul 2006 01:22:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/extract-similar-kind-of-files-through-perl-script/m-p/3817611#M100249</guid>
      <dc:creator>Sasirekha</dc:creator>
      <dc:date>2006-07-06T01:22:26Z</dc:date>
    </item>
    <item>
      <title>Re: extract similar kind of files through perl script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/extract-similar-kind-of-files-through-perl-script/m-p/3817612#M100250</link>
      <description>As the intro said:&lt;BR /&gt;--8&amp;lt;--- untested braindump follows ...&lt;BR /&gt;&lt;BR /&gt;So it was just a reflection of my thoughts.&lt;BR /&gt;It's up to you to complete it.&lt;BR /&gt;&lt;BR /&gt;I cannot test if I don't have a config file.&lt;BR /&gt;My bet is that the config file looks different that your specs&lt;BR /&gt;&lt;BR /&gt;I was quite defensive in my parsing, but if you do not have separators between your patterns, I cannot tell what will happen.&lt;BR /&gt;&lt;BR /&gt;You could start with attaching the config file, so I could suggest some changes.&lt;BR /&gt;I was more or less hoping that my framework (in fact almost complete working code) would get you on the rails.&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Thu, 06 Jul 2006 01:44:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/extract-similar-kind-of-files-through-perl-script/m-p/3817612#M100250</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2006-07-06T01:44:06Z</dc:date>
    </item>
    <item>
      <title>Re: extract similar kind of files through perl script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/extract-similar-kind-of-files-through-perl-script/m-p/3817613#M100251</link>
      <description>1.The script should get the directory entered by the user.&lt;BR /&gt;2.It should scan all the file's extensions in that User directory.&lt;BR /&gt;3.It should match those extensions with the extensions specified in the config file.&lt;BR /&gt;4.If match found it should create a directory in the User given directory path,with name specified for that extension in the config file and put that file in the corresponding newly created directory.&lt;BR /&gt;&lt;BR /&gt;The config file contains like below&lt;BR /&gt; .jpg,*.gif,*.bmp,etc.. -&amp;gt; graphical type files&lt;BR /&gt;*.~*,*.tmp,*.bak,etc.. -&amp;gt; backup type files&lt;BR /&gt;*.pl,*.php,*.tcl,etc.. -&amp;gt; source type files&lt;BR /&gt;in the user entered directory.&lt;BR /&gt;like this ...the extensions might be added up in future for each grap,backup and source.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 06 Jul 2006 02:21:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/extract-similar-kind-of-files-through-perl-script/m-p/3817613#M100251</guid>
      <dc:creator>Sasirekha</dc:creator>
      <dc:date>2006-07-06T02:21:11Z</dc:date>
    </item>
  </channel>
</rss>

