RE: FW: rmdir

2001-09-26 Thread Porter, Chris

Please remove me from the mailing list. 

Thank you.

Chris

-Original Message-
From: Michael Fowler [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 27, 2001 5:27 PM
To: Me
Cc: Porter, Chris; [EMAIL PROTECTED]
Subject: Re: FW: rmdir


On Wed, Jun 27, 2001 at 03:51:43PM -0500, Me wrote:
 Basically, you have to write a sub that does the
 following sort of thing (ignoring your wrinkle that
 you don't want to delete all the files in the initial
 directory):

Or you could use File::Path::rmtree.  I'm surprised no one has given this
answer yet.


Michael
--
Administrator  www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--



RE: Directories

2001-07-20 Thread Porter, Chris

Morning, afternoon, evening,

Could I please have an example of the rmtree function.  Everytime I try to
run this function my script dies on me.  I'm sure I'm just missing a small
part of it.

Any help would be appreciated.  Thank you and have a great day.

Chris

 chdir /u311/world/b25/MAN3/spc or die $!;
 # chdir /u11/tmp or die $!;

 opendir(HERE, '.');

 @AllFiles = readdir(HERE);

 foreach $Name (@AllFiles) {

   if (-f $Name) {next}

   if ((-d $Name) and ($Name =~ /^[A-Z]+$/)) {rmdir $Name or die$!};

  if ((-d $Name)) {print $Name\n} 

-Original Message-
From: Craig Moynes/Markham/IBM [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 10, 2001 9:02 AM
To: Porter, Chris
Cc: '[EMAIL PROTECTED]'
Subject: Re: Directories


 Calling perl gurus,
 Hello,  help please!!!  Looking to delete empty directories, I have a
script
 for that but if the directories have files in them, it dies.  Either can
I
 add some type of script to delete them also or can I just avoid them all
 together and just delete the empty ones.  Any help would be much
 appreciated.  Thank you.
 P.S.  All directories are capital letters, that's how I call them.  All
 lowercase needs to stay in directory.  Thanks again.

I am having some difficulty understanding your question.
If you just want to modify this script so that it does not die if the
directory contains files change the following:

[snip]
if ((-d $Name) and ($Name =~ /^[A-Z]+$/)) {rmdir $Name or die $!};
[snip]
Change this line to:
if ((-d $Name) and ($Name =~ /^[A-Z]+$/)) {rmdir $Name};

Its not pretty or elegant but it solves your immediate problem.
A better solution may be to enter each directory within . and if there
are more than two entries (. and ..)
then you cannot remove this directory.



-
Craig Moynes
[EMAIL PROTECTED]





Directories

2001-07-10 Thread Porter, Chris

Calling perl gurus,

Hello,  help please!!!  Looking to delete empty directories, I have a script
for that but if the directories have files in them, it dies.  Either can I
add some type of script to delete them also or can I just avoid them all
together and just delete the empty ones.  Any help would be much
appreciated.  Thank you.

P.S.  All directories are capital letters, that's how I call them.  All
lowercase needs to stay in directory.  Thanks again.

Chris

#!/opt/perl5/bin/perl -w

#  This script is used to remove capital letters from xxx//b
#  /x/spec directory


chdir /xxx/x/x/x/spec or die $!;
# chdir /u131/tmp or die $!;

 opendir(HERE, '.');

 @AllFiles = readdir(HERE);

 foreach $Name (@AllFiles) {

   if (-f $Name) {next}

   if ((-d $Name) and ($Name =~ /^[A-Z]+$/)) {rmdir $Name or die $!};


   if ((-d $Name)) {print $Name\n}

   }{ die All done.  Thank You!\n } 

   }
rmdir.perl 24 lines, 495 characters   



RE: FW: rmdir

2001-06-28 Thread Porter, Chris

Mike,

Still unsure how to approach.  Very new to perl and I don't want to screw
this up.  Any input from you would be great.  Thank you.

Chris

-Original Message-
From: Michael Fowler [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 27, 2001 5:27 PM
To: Me
Cc: Porter, Chris; [EMAIL PROTECTED]
Subject: Re: FW: rmdir


On Wed, Jun 27, 2001 at 03:51:43PM -0500, Me wrote:
 Basically, you have to write a sub that does the
 following sort of thing (ignoring your wrinkle that
 you don't want to delete all the files in the initial
 directory):

Or you could use File::Path::rmtree.  I'm surprised no one has given this
answer yet.


Michael
--
Administrator  www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--



FW: FW: rmdir

2001-06-27 Thread Porter, Chris



-Original Message-
From: Porter, Chris 
Sent: Wednesday, June 27, 2001 9:21 AM
To: 'Maxim Berlin'
Subject: RE: FW: rmdir


Hi,

It's working great.  Thank you.  But one more thing, it's removing all the
empty directories but what about directories with files in them.  It errors
out when it hits a directory with files in it.  I have just files in this
directory that I don't want to delete.  I only want to delete the
directories with Capital letters and the files in them.  Thank you for any
help or ideas.

Chris

-Original Message-
From: Maxim Berlin [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, June 26, 2001 10:07 AM
To: '[EMAIL PROTECTED]'
Subject: Re: FW: rmdir


Hello Chris,

Tuesday, June 26, 2001, Porter, Chris [EMAIL PROTECTED] wrote:

PC It's me again, still won't work.  Here is the whole script:
PC Again, any help would be great.

Well, script works correct now.

May be you try to rmdir not empty subdirs?

c:\perldoc -f rmdir
rmdir FILENAME
rmdir   Deletes the directory specified by FILENAME if that
directory is empty. If it succeeds it returns TRUE,
otherwise it returns FALSE and sets `$!' (errno). If
FILENAME is omitted, uses `$_'.

you can avoid many troubles, if you check return codes, like this:

rmdir $Name or die $!;

PC  chdir /u131/tmp or die $!;

PC  opendir(HERE, '.');

PC  @AllFiles = readdir(HERE);

PC  foreach $Name (@AllFiles) {

PCif (-f $Name) {next}

PCif ((-d $Name) and ($Name =~ /^[A-Z]+$/)) {rmdir $Name}


PCif ((-d $Name)) {print $Name\n}

PC}  



Best wishes,
 Maximmailto:[EMAIL PROTECTED]




rmdir

2001-06-26 Thread Porter, Chris

Hi, was hoping someone could help.
I want to remove some directories:
.Any help would be greatly appreciated.
Basically, I want to remove all directories with Capital letters in this
directory.  Make sense.
Here is my script, looks like it's working but it's not removing all the
directoriesopendir(HERE, '.');

 @AllFiles = readdir(HERE);

 foreach $Name (@AllFiles) {

   if (-f $Name) {next}

   if ((-d $Name) and ($Name =~ /^[A-Z]+$/)) {rmdir '$Name'}

Thanks.

Chris



FW: rmdir

2001-06-26 Thread Porter, Chris

It's me again, still won't work.  Here is the whole script:
Again, any help would be great.

Thanks.

 
 chdir /u131/tmp or die $!;

 opendir(HERE, '.');

 @AllFiles = readdir(HERE);

 foreach $Name (@AllFiles) {

   if (-f $Name) {next}

   if ((-d $Name) and ($Name =~ /^[A-Z]+$/)) {rmdir $Name}


   if ((-d $Name)) {print $Name\n}

   }  

-Original Message-
From: Maxim Berlin [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, June 26, 2001 9:22 AM
To: '[EMAIL PROTECTED]'
Subject: Re: rmdir


Hello Chris,

Tuesday, June 26, 2001, Porter, Chris [EMAIL PROTECTED] wrote:

PC Hi, was hoping someone could help.
PC I want to remove some directories:
PC .Any help would be greatly appreciated.
PC Basically, I want to remove all directories with Capital letters in this
PC directory.  Make sense.
PC Here is my script, looks like it's working but it's not removing all the
PC directories
PC opendir(HERE, '.');

PC  @AllFiles = readdir(HERE);

PC  foreach $Name (@AllFiles) {

PCif (-f $Name) {next}

PCif ((-d $Name) and ($Name =~ /^[A-Z]+$/)) {rmdir '$Name'}

change
 rmdir '$Name'
to
 rmdir $Name
or to
 rmdir $Name

' and  is very different in perl.


Best wishes,
 Maximmailto:[EMAIL PROTECTED]




Please

2001-06-22 Thread Porter, Chris

UNSUBSCRIBE.

Thanks.



FW: FW: delete files

2001-05-17 Thread Porter, Chris



-Original Message-
From: Porter, Chris 
Sent: Thursday, May 17, 2001 6:59 AM
To: '[EMAIL PROTECTED]'
Subject: RE: FW: delete files


Thanks, helps very much.  The directory -- I added the directory I'm
referring to.
opendir  DIR  - added the same directory()

Can u break this code down for me, sorry being such a newbie newbie
newbie

Muchas gracious

Chris


-Original Message-
From: Paul [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 16, 2001 11:05 AM
To: Porter, Chris; [EMAIL PROTECTED]
Subject: RE: FW: delete files


--- Porter, Chris [EMAIL PROTECTED] wrote:
 Silly question --- where do i exactly insert all of my information
 that points to where my changes need to be made.  Sorry if this is a
 stupid question.  Thank you.

If you don't know, it would be sillier not to ask. =o)

chdir /the/directory or die $!; # === edited 
   opendir DIR, . or die $!;
   for my $file (grep { -f $_ } readdir DIR) {  # maybe -c?
 unlink $file if $file =~ /^[A-Z]+$/
   }
   closedir DIR;

The previous version assumed you had done something like:
  my $dir = /the/directory;

Does that help?

__
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/



FW: FW: delete files

2001-05-16 Thread Porter, Chris

Forwarded message.

-Original Message-
From: Porter, Chris 
Sent: Wednesday, May 16, 2001 7:14 AM
To: '[EMAIL PROTECTED]'; ',[EMAIL PROTECTED]'
Subject: RE: FW: delete files


Silly question --- where do i exactly insert all of my information that
points to where my changes need to be made.  Sorry if this is a stupid
question.  Thank you.

-Chris

-Original Message-
From: Paul [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 15, 2001 11:34 AM
To: Porter, Chris; [EMAIL PROTECTED]
Subject: Re: FW: delete files



--- Porter, Chris [EMAIL PROTECTED] wrote:
 Any ideas???
  me.  I want to create a script that deletes uppercase words from a
  directory using the unlink command.  Probably a very simple thing

  chdir $dir or die $!;
  opendir DIR, . or die $!;
  for my $file (grep { -f $_ } readdir DIR) {  # maybe -c?
unlink $file if $file =~ /^[A-Z]+$/
  }
  closedir DIR;

Print files might be character special files, with would be -c, or some
other sort that would simplify the grep test to a more accurate
version.

What this does:

  chdir $dir or die $!;

Go to the directory in question. This assumes you've already loaded
$dir with that name.

  opendir DIR, . or die $!;

Open the current directory for reading, to get the filenames.

   for my $file (grep { -f $_ } readdir DIR) {  # maybe -c?

Loop through the files (for my $file) in the directory (readdir DIR)
that are plain files (grep { -f $_ })
 --- note that this grep condition is the one that might need to be
 changed to -c instead of -f ---

  unlink $file if $file =~ /^[A-Z]+$/

and unlink each $file returned.

=
print Just another Perl Hacker\n; # edited for readability =o)
=
Real friends are those whom, when you inconvenience them, are bothered less
by it than you are. -- me. =o) 
=
There are trivial truths and there are great Truths.
 The opposite of a trival truth is obviously false.
 The opposite of a great Truth is also true.  -- Neils Bohr

__
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/



FW: delete files

2001-05-15 Thread Porter, Chris

Any ideas???

  -Original Message-
 From: Porter, Chris  
 Sent: Tuesday, May 15, 2001 9:20 AM
 To:   '[EMAIL PROTECTED]'
 Subject:  delete files
 
 Hello,
 
 How are you?  Sorry to bother.  I am very new to perl so please bear with
 me.  I want to create a script that deletes uppercase words from a
 directory using the unlink command.  Probably a very simple thing to do
 but unsure how to approach.  I would like this script to be run once a day
 (I'll take care of that by putting in the crontab).  This particular
 directory fills up with un-needed print files that have been getting
 removed manually for a while.  I want to simplify that.  I hope I
 described my problem okay.  Actually, the files that are being deleted are
 users last names, if that helps any.
 
 Thank you very much in advance.  I hope you can help.
 
 Sincerely,
 
 Chris Porter
 [EMAIL PROTECTED]