Can someone give me an example of how to code a function that creates multiple sub directories
For instance if I pass "c:firstdirseconddirthirddir" to the function and only "c:" exists, that the code will create "c:firstdir" and then "c:firstdirseconddir" and finally "c:firstdirseconddirthirddir"
Steven
I know this was mainly Unix-related, but there might be some generic code in there too:
//http://www.alh.net/newlisp/phpbb/viewtopic.php?t=1295&highlight=mkdir
Playing with dirs :
; dirtest dmemos 29-jul-07
; --- simple function
( change-dir "D:\temp" ) ; my play-dir
( define ( mkdirs mlist )
( dolist ( dirname mlist )
( make-dir dirname )
( change-dir dirname )))
( mkdirs '( "a" "b" "c" ))
; --- same with a macro
( change-dir "D:\temp" ) ; my play-dir
( define-macro ( mkdirs2 )
( doargs ( dirname )
( make-dir (string dirname ))
( change-dir (string dirname))
))
( mkdirs2 "g" "h" "i" ) ; now you don't need a list
( change-dir "D:\temp" ) ; my play-dir
( mkdirs2 d e f ) ; .. and you even don't need strings
; --- small addition : when finished go back to start-dir
( change-dir "D:\temp" ) ; my play-dir
( define ( mkdirs3 mlist )
( set 'start-dir (real-path))
( dolist ( dirname mlist )
( make-dir dirname )
( change-dir dirname ))
( change-dir start-dir ))
( mkdirs3 '( "j" "k" "l" ))
; --- with macro the same
( define-macro ( mkdirs4 )
( set 'start-dir (real-path))
( doargs ( dirname )
( make-dir (string dirname ))
( change-dir (string dirname))
)
( change-dir start-dir ))
( mkdirs4 "m" "n" "o" )
( mkdirs4 p q r )
Maybe you have to parse your string into single dir-names .
PS: it doesn't matter if you apply make-dir on an existing directory
PPS : i wrote this before reading cormullions link - but it's interesting to see it , i've tested my examples under Win2k