#!E:/Perl/bin/perl.exe -w
# =================================== #
# sort.pl - Written by PaTcH #
# ============================== #
# I think it's pretty self explanitory #
# what the program does by the name, #
# and welcome. #
# =================================== #
# /\/\
#(O.o) This is Bunny. Copy Bunny into your signature
#(> <) to help him on his way to world domination.
use strict;
use File::Copy;
&welcome_msg();
my ($workingDir, $arrayNumber, $fileIn, $shifter) = undef;
print "\n\nPlease Enter Working Dir : ";
while(<>)
{
chomp;
$workingDir = $_;
if(!chdir($workingDir))
{
print "Error :$!\n";
} else
{
chdir($workingDir);
print "Files? : ";
my @arrayFiles = glob <STDIN>;
my $arrayNumber=@a;
for my $newNames (@arrayFiles)
{
my $oldNames = $newNames;
$newNames =~ s/\s/_/g;
rename($oldNames, $newNames);
}
print "Please enter a folder name : ";
my $fileIn = <STDIN>;
chomp($fileIn);
if(!-e $fileIn) { mkdir($fileIn) or die "Could not create $fileIn\n"; }
for(my $i=0;$i<$arrayNumber;$i++)
{
$shifter = shift(@arrayFiles);
move($shifter,$fileIn);
print "\n$shifter moved to $fileIn";
}
print "\nEnter Another Directory ("./" without quotes for current) or Cntrl+C to exit...\n";
}
}
sub welcome_msg()
{
print "\n\nYou've Decided to run :\n\n\n";
print "$0\n\n\nWritten by PaTcH/Gnomer\n\n\n";
print "The working are simple, but there\n";
print "are things you should know. If the file name has spaces\n";
print "then it will NOT sort the file. That will be fixed when I release\n";
print "this for the public. If no folder exist, it makes the name\n";
print "you specify.\n\n\n\tThank you, PaTcH/Gnomer\n";
}