Folders and subfolders

Started by jose hidalgo

Folders and subfolders   26 December 2015, 11:32

Hi,
Just to be sure... Here's a picture from RAM Disk manual:
SoftPerfect support forum

Let's assume that I want to create a Folder\Subfolder structure. What should I type exactly in the "Create Folders" dialog ?

Option 1 :
Folder\Subfolder

Option 2 :
Folder
Folder\Subfolder

Option 3 :
I don't know, please tell me ^^

Thanks. smile
SoftPerfect Support forum - Andrew avatar image

Re: Folders and subfolders   26 December 2015, 11:39

If you are creating a logon-time RAM Disk, type normally:

Folder
Folder/Subfolder

If you are creating a boot-time RAM Disk, nested folders are not supported. You could use something like this instead:

Folder
Folder-SubFolder
Martin

Re: Folders and subfolders   25 March 2016, 22:43

Is it possible to add support for nested folders for boot-time RAM disks?
If not, please explain what's preventing this feature from being implemented (Just out of curiosity, because I'm a developer, too. wink).
SoftPerfect Support forum - Andrew avatar image

Re: Folders and subfolders   26 March 2016, 09:02

Because we create the required file system structures manually. At that stage during system startup the functions to create directories are not available. Instead we have to manually create a file table and everything.

It's relatively straightforward for FAT/FAT32 and much more complicated for NTFS. Nested folders are even harder, so we didn't implement this feature.

Re: Folders and subfolders   25 May 2016, 21:43

Hi Jose,

You can use a batch file to achieve this. For example the following should work:
:: This Batch File Creates Sub-Folders in a Ramdisk
ping -n 2 127.0.0.1 >NUL
mkdir w:\Folder\Sub-Folder\Sub-Sub-Folder
mkdir "w:\Folder Names\With Spaces\In Them"
pause
exit

To explain what that would do:

Line 1
This is just a "remark line" that you can read in the batch file that says what the batch is for.

Line 2
The 'ping' instruction just pings (in this case) your own machine (and, in this case, throws away the response to the ping).

The "-n 2" part just says how many pings should be performed and the system does that number of pings at, by system default, one second intervals, though the first ping happens instantly. While the batch file is doing the pings the system cannot go to the next instruction in the batch as it has to wait for all the pings to be performed before moving to the next line. So this is a good technique to use in a batch file to force a "wait" before going to the next instruction in the batch. So for "-n 2" this is effectively forcing the batch file to wait for 1 second before moving to the next instruction in the batch. You can use any number of pings you want e.g. -n=6 for a 5 second delay, -n=21 for a 20 second delay, (and so on). For your purposes you need an "-n" value that lets the ramdisk be created on the system before you start to create the folders/sub-folders.

The "127.0.0.1" part is just the address of your local machine. So that is what you are pinging, not somewhere on the internet.

The ">NUL" part is just an instruction to the throw the result of the ping away. We aren't interested in the response to each ping.

Line 3
The "mkdir" is short for "make directory" (or "make folder" in other words). The "w:\" part of the instruction should be the disk label of your ramdisk. Note that because there are no spaces in the paths to the folders you do not need to enclose the path in double-quotation marks.

Line 4
Here we are creating folders that have spaces in their names. To do this the complete path must be enclosed in double-quotation marks. (Look carefully at the difference between "Line 1" and "Line 2" and you will see what I mean.)

Line 5
"pause" just forces the batch file window to remain open until you press a key. This is useful so that if you make a batch file and test it you can get to read any messages the batch creates in response to the instructions in the batch. In a working batch file that has been tested you might not want this "pause" so just delete that line once you're happy that the batch works. Once that "pause" has been deleted the batch will just run through all the instructions and the window will close automatically when the last instruction has been done. (An alternative to deleting the "pause" instruction is just to "Rem It Out".)

Line 6
"exit" is just terminating the batch file nicely for the system.

In this way you can easily create whatever folders/subfolders you want in your ramdisk. Just make a shortcut to the batch file in your "Startup" menu. So when the system boots the batch file gets launched and will create the folder structure you require. Just do enough pings in the batch to cover the amount of time it takes for the ramdisk to be created on system boot.

If you experiment with the above then you might solve whatever problems you have with creating sub-folders at boot-time.

Hope this helps.

Re: Folders and subfolders   26 May 2016, 01:21

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. smile
SoftPerfect Support forum - Andrew avatar image

Re: Folders and subfolders   26 May 2016, 09:34

A boot-time RAM Disk is initialised an early stage during system boot, so unless something went wrong it always exists by the time your batch file runs.

There's an issue with the above solution though. As you may know, a boot-time RAM disk is created and made ready even before a user logs on. This way it can be used with service processes, for example.

However a shortcut in the Startup folder only runs when a user logs on. If no one logs on, there will be no folders. This essentially makes the solution the same as using a logon-time RAM Disk, which allows nested folders that are created upon logon.

Re: Folders and subfolders   26 May 2016, 20:07

Okay, thanks very much for the clarification, Andrew. Starting to understand a bit how and when the ramdisk gets created.

Sometimes you can find a solution faster if you try the forum search, have a look at the knowledge base, or check the software user manual to see if your question has already been answered.

Our forum rules are simple:

  • Be polite.
  • Do not spam.
  • Write in English. If possible, check your spelling and grammar.

Author:

Subject

A brief and informative title for your message, approximately 4–8 words:

     

Spam prevention: please enter the following code in the input field below.

  *******   **     **  **     **  **    **  **     ** 
 **     **  **     **  **     **   **  **   **     ** 
 **     **  **     **  **     **    ****    **     ** 
  ********  **     **  **     **     **     **     ** 
        **  **     **  **     **     **     **     ** 
 **     **  **     **  **     **     **     **     ** 
  *******    *******    *******      **      *******  

Message: