mIRC Home    About    Download    Register    News    Help

Print Thread
#208990 02/02/09 07:28 PM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
var %file1 = folder/blah.txt
var %file2 = folder/subfolder/subsubfolder/blahyy.txt

if (!$isifle(%file1)) ...

if (!$isfile(%file2)) ....

how can i make a function to create the folder and subfolders if it doesnt already exist? i understand mkdir folder works but mkdir folder/subfolder/subsubfolder does not.

Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Use /mkdir in a loop.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
could you show me how i can do that?

Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
Quote:
how can i make a function to create the folder and subfolders if it doesnt already exist? i understand mkdir folder works but mkdir folder/subfolder/subsubfolder does not.


Sure it does.

Here is an excerpt from my script.

Code:
if (!$isdir(lists\axis)) { if (!$isdir(lists)) { mkdir lists } | mkdir lists\axis }
if (!$isdir(lists\users)) { mkdir lists\users }


Maybe because your slashes are backwards. Use / for internet, \ for local. Usually windows has no problem translating these.

Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
I think he was stating that /mkdir can't be used to create multiple folder.For the OP, try :

Code:
alias mkdir_ {
  tokenize 32 $noqt($1-)
  var %a = 1, %b = $numtok($1-,92)
  while (%a <= %b) {
    var %p = $qt($gettok($1-,1- $+ %a,92))
    if (!$isdir(%p)) mkdir %p
    inc %a
  }
}
use it like /mkdir, but all the directory that doesn't exist will be created first.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel

Link Copied to Clipboard