Aikon Posted July 23, 2011 Report Share Posted July 23, 2011 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. Link to comment Share on other sites More sharing options...
err0r Posted July 23, 2011 Report Share Posted July 23, 2011 nice addon my only suggestion is on the variables.. instead of just setting %b you could just var %b like you did with %a then there is no need to unset %a and %b. There is also a snippet section on the site where you could add these located here http://www.tg007.net/page/snippet again well done, good idea. Link to comment Share on other sites More sharing options...
Aikon Posted July 23, 2011 Author Report Share Posted July 23, 2011 I thought I had 'set %a' also...my bad. I didn't feel it was worthy the bandwidth to upload as a file in its own right. But if you insist, I'll fix the 'set' and ad /* comment tags */ then upload it to the appropriate section. Thank you for the feedback! Link to comment Share on other sites More sharing options...
Fanfare Posted July 24, 2011 Report Share Posted July 24, 2011 (edited) Adding to err0r's suggestion, you can include the -l switch for your set command. The -l switch makes it local: set -l %a value set -l %b value This makes them function exactly the same as the /var option. The -l switch is undocumented. Edited July 24, 2011 by Fanfare Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now