I found it annoying to have to make folders for things like log keeping in my script...it usualy looked something like this
if (!$isdir(foldername)) { mkdir foldername }
if (!$isdir(foldername\subfolder)) { mkdir foldername\subfolder }
To ease the keystrokes I came up with this alias;
alias mkf {
tokenize 32 $1-
var %a 1
while (%a <= $numtok($1-,32)) {
set %b $+(%b,$gettok($1-,%a,32),\)
mkdir %b
inc %a
}
unset %a , %b
}Use:/mkf foldername1 foldername2...foldernameN
if you want to make more than one sub folder in any given folder simply repeat the command
/mkf soldername1 foldername2.5
and you now have two second level sub folders!
Note:
This can potentialy make an infinate amount of nested folders. I tested it up to one hundred nested folders with no problems!
~^v~^v~^v~^v~^v~^v~^v~^v~^v~^v~^v~^v~^v~^v~^v~^v~^v
It became even more tedious when I had things like the date or the time as the folder name. So to make it simple(ish) I made this.
alias fdate {
return $date(dddd-mmmm-dd-yyyy)
}
alias ftime {
return $time(hh.nn.ss.TT)
}Use:/mkf logs fdate
Now I can have tmy log files sorted by date with a few keystrokes!
Closing comments
I could probabley add a line to the mkf alias to check if the folder exists...
"...
if (!$isdir(%
) {
mkdir %b
...
"
but it works fine the way it is now.
I hope this is found to be useful to someone...if you use this snippet - even if you change it in any way - please send me a copy of the script you used this in. That way I can learn and grow in my ability.