Hi Jose,
I just thought of another way of doing this. One of the problems with the batch described above is that if you the timing is wrong then the folders might never be created before the batch exits. -n=[whatever] is a potential failure point for the script. The following batch gets round this as it isn't reliant on the user getting the timing right - the script keeps running until it can create the folders. The problem with it is that if it can never create the folders the script will keep running, forever if needs be, until it can make the folders. In effect the script is based on an infinite-loop that can only be exited automatically by the folders actually managing to be created. To get out of the loop if the folders can't be created the user needs to manually close the batch window. This is, as far as I'm aware, regarded as "bad programming" - but, hey, it works! Actually, in a script this short it isn't really a problem as far as I'm concerned.
:start
if exist w: goto :makefolders
if not exist w: goto :start
:makefolders
mkdir w:\Folder\Sub-Folder\Sub-Sub-Folder
mkdir "w:\Folder Names\With Spaces\In Them"
pause
exit
For Line 1 and Line 5
":start" and ":makefolders" are just line-labels in the script - they allow being able to force the script to jump (using the "goto" instruction) to that line-label in the script and line-by-line follow any instructions that follow that line.
For Line 2
This is just checking to see if the ramdisk drive exists. On my system the ramdisk drive has label "w:". To use the script you will need to alter
all instances of the ramdisk drive label,
including the lines with paths to folders, to suit what is actually on your own system.
"goto :makefolders" just jumps the script to that label line in the script. Once it gets to that line the script will execute, line-by-line, all the lines that follow.
For Line 3
This is pretty much the same as Line 2 except that now the script is saying, if the ramdisk drive label "w:"
does not exist (
i.e. the ramdisk isn't yet mounted) then goto the script line labelled ":start". Which, of course, just means go back to the start of the script and try and see again if the ramdisk is mounted yet. (You should be able to see that the script jumping back to ":start" is forcing a loop to occur.) Once the ramdisk is mounted the script will notice this, as per Line 2, create the folders and exit the batch.
You should, given my comments for the first script I posted, be able to see how the rest of the batch works and what to do about the "pause" if you don't want that actioned in the script. I've tested this on my own system in the following two ways:
Test 1
(1) Unmount the ramdisk from within the "SoftPerfect RAM Disk" window.
(2) Launch the batch file.
(3) As the ramdisk doesn't exist you will see the batch file performing a fast loop (running till it finds the existence of the ramdisk).
(4) With the batch file still running, mount the ramdisk. As soon as the batch registers the presence of the ramdisk it will create the folders.
Test 2
(1) Create a shortcut to the batch file in the "Startup" menu.
(2) Reboot the computer.
(3) The script auto-launches, finds the ramdisk and creates the folders. Actually on my test of this, with the "pause" instruction in the script remmed out, this happened so quickly that the batch window just flashed up then was gone. I suspected that the ramdisk already exists before the batch file gets launched from the "Startup" shortcut - so this is pretty well instant. To test if that was or wasn't the case, I did a reboot with the "pause" instruction not remmed out. Sure enough it was clear that the batch never ran the loop even once, it just registered the ramdisk and immediately created the folders - which means, at least on my system, that the ramdisk exists before the batch file even gets launched from the "Startup" shortcut. With that in mind, assuming that this always the case, then the following batch would work just as well:
mkdir w:\Folder\Sub-Folder\Sub-Sub-Folder
mkdir "w:\Folder Names\With Spaces\In Them"
exit
But, then, do you want to take the risk that the ramdisk is always going to be there
before the batch file gets launched?
In any case, there are three variations on a theme that might solve the problem, Jose.