Hi people,

I have a CGI script that uploads files, performs a bundle of checks upon then and then if they are valid I want to move all files in that directory into a processing directory where a cron job operates on them once a day

(I have uploaded a bundle of files in a tar file and unziped them using Archive::Tar into this directory)

The uploaded files look like..

[277] mf139823@esweb: pwd /apps/webroot/service/servicelist-automation/sl-submission/submitted-f +iles/2002-10-28-11-42-09-ss-mrf2 [278] mf139823@esweb: ls -l total 66 -rwxrwxrwx 1 nobody nobody 17408 Oct 28 11:42 siteresse-sg-eng +.tar -rwxrwxrwx 1 nobody nobody 7361 Oct 22 09:49 siteressse-sg-en +g-20020510.sxw -rwxrwxrwx 1 nobody nobody 7357 Oct 22 09:49 siteressse-sg-en +g-20020918.sxw

...now the code I have to move them looks like this...

sub moveTarFilesToProcessDir{ # $fileFrom = "$curSubmitDir/siteressse-sg-eng-20020918.sxw"; $fileFrom = "$curSubmitDir/*"; $fileTo = "$thisFilesDir/new-files/$user_LOB/"; print $cgi->p("Moving files from <h4>($fileFrom)</h4> to <h4>($fil +eTo)</h4>"); move($fileFrom, $fileTo) or die "($!)"; }

... you'll noitice that one line is commented out. If I use this line instead of the line under it as the $fileFrom variable it will move just that file to the correct place(thats one of the files I'm testing it with)

But I want to move all files in this directory. So why does $fileFrom = "$curSubmitDir/*"; not work? How can I move all of the files in this directory.

At the moment I get the error..

(No such file or directory)

... when I try to use $curSubmitDir/*

Is this a stupid mistake that has kept me puzzled for a the last 3hours or is it not possible with File::Copy?

Thanks everyone,

M


In reply to Move multiple files? by heezy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.