Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
i need a simple shell script for unix, however im completely useless at shell scripting and cant get past the #!/bin/sh bit 8(....
what i desperately need to do is move files from my current directory into subdirectories depending on the first letter of its name, (eg.Accounts/A54mJU would be put into a subdirectory called A).
Subdirectories should only be created if there's files to be put into them (ie. no empty subdirectories)
and last of all a file called catalogue.txt should be created in my current directory listing all of the files which have been relocated, grouped by letter....
if any answers or help can be given i would be forever grateful...
thanks... Janet

janetProblemSolved.pl this is a perl script which takes the absolute path of the directory for which subdirectories are to formed only care to be taken is that ther should be no file with a single letter as a name
i hope this serves ur purpose
art -----------------
#!/usr/local/bin/perl -wmy $dir = shift ;
chomp $dir ;
my %catalogue=();
my $add=();
opendir (HANDLE, "$dir") or die " cant open the directory file \n";
@files = readdir(HANDLE);
$countFiles = scalar(@files);
close HANDLE;
for($i = 2; $i >$dir/catalogue.txt") or die " cant open the file to write \n";
foreach $letter ( sort keys %catalogue) {
print FILE "files for letter $letter \n";
foreach $document ( @{$catalogue{$letter}}) {
print FILE " $document \n";
}
}close FILE ;
close HANDLE;
-----

![]() |
Folder Permissions Questi...
|
script required
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |