I use Windows at work, and use my Desktop as a workspace. However, I often am too lazy to clean my desktop off (which really just involves moving documents into a directory, archives into an 'Apps' directory {they are usually downloads}, and shortcuts off to a 'Shortcuts' directory). So, I let Perl do the heavy lifting for me:

package main; use strict; use warnings; our $VERSION = '0.01'; our $BUILD = 'Oct 24, 2005'; #__modules__ use POSIX qw[_exit]; use Win32::TieRegistry; use File::Spec::Functions ('catdir','catfile'); use File::Copy; main( \@ARGV ); #_____________________________________________________________________ +__ main()_ sub main { # main ( \@argv ) my $argv = shift; $Registry->Delimiter('/'); my $sh_fold = $Registry->{'HKEY_CURRENT_USER/Software/Microsoft/Wi +ndows/CurrentVersion/Explorer/Shell Folders'}; my $desk = $sh_fold->{'Desktop'}; my $docs = $sh_fold->{'Personal'}; chdir $desk; opendir my $DESK, $desk or die ('Opening Desktop: '.$!); my (@doc, @dir, @exe, @lnk); for (readdir $DESK) { next if /^\.{1,2}$/; # skip . and .. if ( -d $_ ) { push @dir, $_ and next } next unless -f $_; # executable and other "non-document" types if ( /\.(?:exe|zip|tgz|tar|gz|com|msi|ini)$/i ) { push @exe, $_; } elsif (/\.lnk$/i) { next if /^CleanDesk/i; push @lnk, $_; } else { push @doc, $_; } } my $newdir = catdir($docs, 'Cleaned'); mkdir $newdir; $|=1; for (@doc) { print $_,' => '; my $new = catfile($newdir,$_); copy($_, $new) or do { warn "Skipping $_: $!"; next; }; print $new,"\n"; unlink($_); } mkdir catdir($newdir,'Apps'); for (@exe) { print $_,' => '; my $new = catfile($newdir,'Apps',$_); copy($_, $new) or do { warn "Skipping $_: $!"; next; }; print $new,"\n"; unlink($_); } for (@dir) { print $_,' => '; system('move',$_,$newdir); print catdir($newdir,$_),"\n"; } mkdir catdir($newdir,'Shortcuts'); for (@lnk) { print $_,' => '; my $new = catfile($newdir,'Shortcuts',$_); copy($_, $new) or do { warn "Skipping $_: $!"; next; }; print $new,"\n"; unlink($_); } _exit(0); } #_____________________________________________________________________ +_____ END_ _exit(250); ## unknown exit code. Should *never* happen; __END__ =head1 cleandesk.pl Cleans Desktop items into the My Documents folder =cut
<-radiant.matrix->
A collection of thoughts and links from the minds of geeks
The Code that can be seen is not the true Code
"In any sufficiently large group of people, most are idiots" - Kaa's Law

In reply to Re: Private Utilities by radiantmatrix
in thread Private Utilities by Ovid

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.