Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Creating new folders

by ww (Archbishop)
on Feb 03, 2008 at 03:25 UTC ( [id://665791]=note: print w/replies, xml ) Need Help??


in reply to Creating new folders

Can't reproduce the problem under W2k and AS 5.8.8.

perl -v
This is perl, v5.8.8 built for MSWin32-x86-multi-thread
(with 33 registered patches, see perl -V for more detail)
...
Binary build 819 [267479] provided by ActiveState http://www.ActiveState.com Built Aug 29 2006 12:42:41

OP's path is only 62 chars, at most, so that's not the issue. So, starting with no directory, "test," extant in C:\

C:\>dir t* ... Directory of C:\ 09/04/2006 11:26a <DIR> TEMP 0 File(s) 0 bytes 1 Dir(s) 10,945,437,696 bytes free

Quoting varied from OP's, solely (AFAIK) because the following is run as a one-liner:

C:\>perl -e "if (!-d 'c:/test') {mkdir 'c:/test1';}" C:\>dir t* ... Directory of C:\ 09/04/2006 11:26a <DIR> TEMP 02/02/2008 10:14p <DIR> test1 0 File(s) 0 bytes 2 Dir(s) 10,945,437,696 bytes free

...and, further variance this time in both quoting and slash direction:

C:\>perl -e "if (!-d 'c:/test') {mkdir \"c:/test\";}" C:\>dir t* ... Directory of C:\ 09/04/2006 11:26a <DIR> TEMP 02/02/2008 10:17p <DIR> test 02/02/2008 10:14p <DIR> test1 0 File(s) 0 bytes 3 Dir(s) 10,945,404,928 bytes free

So, are you sure your code is not working? ...sure that E:\ exists and is writable? ... Update - addition ...sure that all the dirs between E:\ and the first you're trying to create actually exist? (See the second bullet in plobsing's reply, above.)

Replies are listed 'Best First'.
Re^2: Creating new folders
by Eagle_f91 (Acolyte) on Feb 03, 2008 at 03:55 UTC
    I know it was not working when I wrote this post as I tried and it did not create the errors. But when I tried agin (afte adding the die command to get errors) everything worked fine. Not sure what was going on
      Not sure what was going on

      There are several possibilities, but the most important lesson to learn from this is always record your error messages. Error messages are your friends.

      Three common errors beginners make on Windows:
      1. Failing to save their script edits.
      2. Saving to the wrong folder, i.e. running a different version of the script to the one they are editing.
      3. Failing to refresh Windows Explorer. Your script may have actually worked first time, but if you checked with a GUI it might not have given an up-to-date view.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://665791]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-26 01:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found