codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Script Does Folder Exist – If Not Create It  Lamont1701 at 03:27 on Tuesday, September 19, 2006
 

Hello People,

I need a Windows 2003 server, Perl 5 Script, that will check to see if a Folder exist, and if the Folder does not exist, then create that Folder. (If the Folder does exist, then do nothing.)

I know nothing about Perl 5 yet, but I have a script running now that needs attention, like yesterday!


Is it possible for someone to help me?



  Re: Script Does Folder Exist – If Not Create It  S_Flex at 11:56 on Tuesday, September 19, 2006
 

This code will work for linux and windows running Perl.

There are some rules when using mkdir() . The mkdir() module will only make one directory at a time. With the path given "C:/Perl/server/Path" if 'server' folder isnt there the 'Path' folder will not be made nor will the server folder. if all folders but the 'Path' folder is made the module will make the folder 'Path'. I thinks............ lol...

# windows Perl systems changes the back slash with a forword slash
# for the Paths name. So what was "C:\Perl\server\Path" is now below
my $file_path = "C:/Perl/server/Path";
# Note: If you what to know if the folder is there use
# if(-d "$file_path") { } # without the !
if(!-d "$file_path") { # if there is !no! directory!
mkdir("$file_path", 0777) # make it and for linux CHMOD to 777
}

<Added>

Sorry at mkdir("$file_path", 0777) # make it and for linux CHMOD to 777

you will need to add a ; like this

mkdir("$file_path", 0777); # make it and for linux CHMOD to 777








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  Searching a string
•  Need Code
•  ASP Sendmail has huge delay
•  help
•  help
•  How to lock SDBM file when that file is writing by multiple programs at the same time
•  How to host C++ Web Service in Apache
•  Re: dynamic crystal report generation
•  XML Parsing Error


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2008