Professional Web Applications Themes

Removing many files and subdirectories under a folrder - PERL Beginners

On Mon, 4 Oct 2004 00:26:22 -0700 (PDT), Denzil Kruse <com> wrote:  What if its windows system? blahhh... :-000ps..!! Moreover if it was some other **ix type system, I don't think the above code will smell right when cooked. Thats what i guess though. :-)   > >[/ref] Yes it can be done using Perl. Read some doc... There are in-built functions called rmdir, mkdir and many more.. Good way to start is 'perldoc perlfunc' for it. [snip] -- Cheers, SanoBabu...

  1. #1

    Default Re: Removing many files and subdirectories under a folrder

    On Mon, 4 Oct 2004 00:26:22 -0700 (PDT), Denzil Kruse
    <com> wrote: 

    What if its windows system? blahhh... :-000ps..!!
    Moreover if it was some other **ix type system, I don't think the
    above code will smell right when cooked. Thats what i guess though.
    :-)
     
    >
    >[/ref]
    Yes it can be done using Perl. Read some doc... There are in-built
    functions called rmdir, mkdir and many more.. Good way to start is
    'perldoc perlfunc' for it.

    [snip]


    --
    Cheers,
    SanoBabu
    Sano Guest

  2. #2

    Default Re: Removing many files and subdirectories under a folrder

    Well

    unlink <./mydir/*>

    worked as i expected for all the files but not directories.


    ----- Original Message -----
    From: "Sano Babu" <com>
    To: "perlmailing List" <org>
    Sent: Monday, October 04, 2004 11:01 AM
    Subject: Re: Removing many files and subdirectories under a folrder

     
    >
    > What if its windows system? blahhh... :-000ps..!!
    > Moreover if it was some other **ix type system, I don't think the
    > above code will smell right when cooked. Thats what i guess though.
    > :-)

    > >
    > >[/ref]
    > Yes it can be done using Perl. Read some doc... There are in-built
    > functions called rmdir, mkdir and many more.. Good way to start is
    > 'perldoc perlfunc' for it.
    >
    > [snip]
    >
    >
    > --
    > Cheers,
    > SanoBabu
    >
    > --
    > To unsubscribe, e-mail: org
    > For additional commands, e-mail: org
    > <http://learn.perl.org/> <http://learn.perl.org/first-response>
    >
    >[/ref]

    John Guest

  3. #3

    Default RE: Removing many files and subdirectories under a folrder

    John wrote: 

    No; you need to write a script. You might look at
    http://ppt.perl.org/commands/rm/index.html for an implementation of rm(1) in
    Perl.
    Bob Guest

  4. #4

    Default Re: Removing many files and subdirectories under a folrder

    >>>>> "John" == John <uoi.gr> writes:

    John> can the above be done with one perl function?

    use File::Path qw(rmtree);
    rmtree('/some/path/to/the/top');

    --
    Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
    <com> <URL:http://www.stonehenge.com/merlyn/>
    Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
    See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
    Randal Guest

  5. #5

    Default RE: Removing many files and subdirectories under a folrder

    Bob Showalter wrote: 
    >
    > No; you need to write a script.[/ref]

    Oops, I guess you can do it in one function. Sorry 'bout that :~)
    Bob Guest

  6. #6

    Default Re: Removing many files and subdirectories under a folrder

    On Mon, 04 Oct 2004 11:09:43 +0300, John wrote:
     
    read 'perldoc -f unlink' for hints on how remove directories.

    Chris Guest

  7. #7

    Default Re: Removing many files and subdirectories under a folrder

    On 04 Oct 2004 05:15:04 -0700, Randal L. Schwartz <com> wrote: [/ref]
    >
    > John> can the above be done with one perl function?
    >
    > use File::Path qw(rmtree);
    > rmtree('/some/path/to/the/top');
    >[/ref]
    If the directory has read-only permission shouldn't the program report
    "read-only directory. Can't delete !" or something without having to
    explicitly die?? Are the semantics heading the right way here?? It
    seems rmtree is doing 'chmod +wx' or something here before deleteing
    the dir/file, is it right or is it implementation dependent via the
    programmer?
     

    [snip]

    --
    Cheers,
    SanoBabu
    Sano Guest

  8. #8

    Default Re: Removing many files and subdirectories under a folrder

    From: Sano Babu <com> 
    > > John> can the above be done with one perl function?
    > > use File::Path qw(rmtree);
    > > rmtree('/some/path/to/the/top');[/ref]
    >
    > If the directory has read-only
    > permission shouldn't the program report "read-only directory. Can't
    > delete !" or something without having to explicitly die?? Are the
    > semantics heading the right way here??[/ref]

    die() does NOT mean "write a message to STDERR and exit the program".
    It means "throw an exception. If noone catches the exception print
    the message to STDERR and exit the program.)

    See eval BLOCK in
    perldoc -f eval

    HTH, Jenda
    ===== cz === http://Jenda.Krynicky.cz =====
    When it comes to wine, women and song, wizards are allowed
    to get drunk and croon as much as they like.
    -- Terry Pratchett in Sourcery

    Jenda Guest

Similar Threads

  1. files in subdirectories won't play?
    By TexasToast in forum Macromedia Flash Flashcom
    Replies: 2
    Last Post: June 26th, 12:59 PM
  2. Removing Old Files??
    By VisOb in forum Macromedia Contribute General Discussion
    Replies: 9
    Last Post: June 20th, 05:00 PM
  3. get list of files in subdirectories?
    By Shaunn Johnson in forum PERL Beginners
    Replies: 4
    Last Post: December 25th, 01:24 AM
  4. Replies: 2
    Last Post: October 18th, 10:56 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139