|
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?
|
|
|
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
|
|
|
|
|
|
|
// |