BatchMD

Title BatchMD
File Name BatchMD.txt
Description Make many directories
Author Vochomurka
Parameters "%p", Before, Start, End, After
Plugins Called win, file
Icon
Version 1.0
Updated on 21.08.2008
args Path, Before, Start, End, After
local hwnd = win.handle("c=TTOTAL_CMD")
local Temp, i, Str

if(Start >= End) do
	Temp = "Starting value of the counter (" ++ Start ++ ") must be less than "
	Temp = Temp ++ "ending value (" ++ End ++ ")"
	messagebox("ok error", Temp, "BatchMD Script")
	quit
endif

if(Start < 0 || End < 0) do
	messagebox("ok error", "Counter must be non-negative value", "BatchMD Script")
	quit
endif

for(i = Start; i <= End; i++)
	Temp = Path ++ Before ++ i ++ After
	if(file.validpath(Temp)) do
		messagebox("ok error", "Folder " ++ Temp ++ " already exisis", "BatchMD Script")
		quit
	endif
	Str = "/c md " ++ Temp
	file.runwait(0, "cmd", Str, "", "hide")
endfor

win.sendmessage(hwnd, 0x400+51, 540, 0)

Comments:

How to create many directories at once? We can use the "New directory" (F7) command: "dir-a|dir-b|dir-c", etc. If directories to create have arbitrary names, it's the fastest way. We can also use a batch file with something like for %%a in (dir-a dir-b dir-c) do md %%a.

The present script allows to create many directories with names containing a counter, for example, Dir-15th, Dir-16th, Dir-17th. To do so, pass the following parameters to the script:

  1. First parameter is a current path (always "%p");
  2. Second parameter is an arbitrary string to put before the counter ("Dir-" in our case);
  3. Third parameter is a starting value of counter (15);
  4. Fourth parameter is an ending value (17);
  5. Fifth parameter is a string to add after the counter ("th").

All Scripts Total Commander TotalCmd.net PowerPro