Note that again, a file tmp.ini (in the script's folder) will be used, and removed. So if you already use such a thing and don't want it to be gone, make the necessary adjustments.
Also, you will need to switch recursion checker off or you'll get a lot of warnings...
Code: Select all
"Batch New Items... : BatchNewItems"
// files or folders ?
$is_file = confirm("Do you want to create files, or folders ?<br><br>OK = Files<br>Cancel = Folders","<br>");
// ask for new items' names
input $names, "Enter new ".(($is_file) ? "files" : "folders")."' names", <clipboard>, m;
// get last 2 bytes
substr $check, $names, -2;
// and make sure it ends with a CRLF
$names = $names . (($check == <crlf>) ? "" : <crlf>);
// switch to one-line
replace $names, $names, <crlf>, "|";
// and store names
setkey $names, "Names", "BatchNewItems", "tmp.ini";
// store type
setkey $is_file, "IsFile", "BatchNewItems", "tmp.ini";
// start creating loop if something to do
sub ($names == "|") ? "_bniNothing" : "_bniLoop";
"_bniNothing"
sub _delTmpIni;
status "No name specified",,stop;
"_bniLoop"
// get type
getkey $is_file, "IsFile", "BatchNewItems", "tmp.ini";
// get list of names
getkey $names, "Names", "BatchNewItems", "tmp.ini";
// search for the first item
strpos $pos, $names, "|";
// and "extract" it
substr $name, $names, 0, $pos;
// remove item from list of names
substr $names, $names, $pos + 1;
// saves new list
setkey $names, "Names", "BatchNewItems", "tmp.ini";
// script to create the new file/folder
$script = 'new "'.$name.'", '.(($is_file) ? 'file' : 'dir').';';
// create item if there's a name
load (($name == "") ? 'incr $void;' : $script),,s;
// we only continue if there is another name
sub ($names == "") ? "_delTmpIni" : "_bniLoop";
"_delTmpIni"
setkey 1, "FileExists", "Ensure", "tmp.ini";
self $path, path;
delete 0, 0, "$path\tmp.ini";