Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 94585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:31:29+00:00 2026-05-10T23:31:29+00:00

I am converting a linux script from http://www.perlmonks.org/index.pl?node_id=217166 specifically this: #!/usr/bin/perl -w use strict;

  • 0

I am converting a linux script from http://www.perlmonks.org/index.pl?node_id=217166 specifically this:

#!/usr/bin/perl -w use strict; use Getopt::Std; use File::Find;  @ARGV > 0 and getopts('a:', \my %opt) or die << 'USAGE'; # Deletes any old files from the directory tree(s) given and # removes empty directories en passant. usage: $0 [-a maxage] directory [directory ...]        -a  maximum age in days, default is 120 USAGE  my $max_age_days = $opt{a} || 120;  find({     wanted => sub { unlink if -f $_ and -M _ > $max_age_days },     postprocess => sub { rmdir $File::Find::dir }, }, @ARGV); 

my attempt is:

#!/usr/bin/perl -w use strict; use Getopt::Std; use File::Find;   @ARGV > 0 and getopts('a:', \my %opt) or die << 'USAGE'; # Deletes any old files from the directory tree(s) given and # removes empty directories en passant. usage: $0 [-a maxage] directory [directory ...]        -a  maximum age in days, default is 120 USAGE  my $max_age_days = $opt{a} || 120;  find({     wanted => sub { unlink if -f $_ and -M _ > $max_age_days }, #    postprocess => sub { rmdir $File::Find::dir },     postprocess => sub {                         my $expr = '$File::Find::dir';                         $expr =~ s/\//\\/g;      # replace / with \                         print 'rmdir $expr\n';                         `rmdir $expr`;                         }, }, @ARGV); 

However I get an error when the script tries to remove a directory saying that the directory is in use by another process (when it isn’t). Any ideas? I’m running the script on Windows Server 2003 SP2 64-bit using ActiveState 5.10.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T23:31:29+00:00Added an answer on May 10, 2026 at 11:31 pm

    From this documentation

    postprocess

    The value should be a code reference. It is invoked just before leaving the currently processed directory. It is called in void context with no arguments. The name of the current directory is in $File::Find::dir. This hook is handy for summarizing a directory, such as calculating its disk usage. When follow or follow_fast are in effect, postprocess is a no-op.

    This means that your own code is still using the directory as you try to delete it. Try building a list of names and iterating through that after the call to find.

    Another possible solution is to use the no_chdir option to avoid having find use the directories you want to delete.

    EDIT: This comment is also relevant, so i’m promoting it to the main answer’s body:

    To add to that: the issue here is that on Linux one can delete files and directories that are in use, on windows one can’t. That’s why it doesn’t work unmodified. – Leon Timmermans

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 68k
  • Answers 68k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Since it says that leading and trailing whitespace are removed,… May 11, 2026 at 12:20 pm
  • added an answer http://msdn.microsoft.com/en-us/library/bb200105.aspx#ID2EWD Looks like you'll need to use Microsoft.Xna.Framework.Storage and the… May 11, 2026 at 12:20 pm
  • added an answer Thanks for all the answers and help guys... I'm actually… May 11, 2026 at 12:20 pm

Related Questions

I am converting a VB6 to C# and I want to make my data
I am from a c# background and am converting a vb.net windows forms app
I am presently working on converting a 32-bit application into a 64-bit application in
I am converting from existing CVS repository to SVN repository. CVS repository has few

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.