Automatic deletion of files in a RAM Disk folder

Started by Claus

Claus

Automatic deletion of files in a RAM Disk folder   19 March 2024, 19:14

Is there an option to make RAM Disk automatically delete the files, that are copied to it?

I just want to have a lower for files, where I can copy files into in a loop. RAM Disk would have to have endless space. As this is impossible, I want RAM Disc to NOT save the files that are copied to it at all.
Or can I delete the files in a RAM Disk folder by command line without a prompt to confirm?
SoftPerfect Support forum - Andrew avatar image

Re: Automatic deletion of files in a RAM Disk folder   20 March 2024, 09:46

It sounds like you want to use a RAM disk in a way that essentially doesn't retain files, effectively copying them to a "black hole" where they're immediately discarded. This might be useful in certain scenarios, such as testing file transfer speeds without actually storing the data, or perhaps when working with sensitive data that shouldn't be written to disk due to security policies.

Method 1: Copying to a NUL device

If your goal is to simply "copy files to nowhere," and you're using a Windows environment, you can copy files to the NUL device. The NUL device is a special file that discards all data written to it. Here's how you can do it from the command line:
cmd
copy yourfile.txt NUL
This command simulates the copying process of yourfile.txt but doesn't actually store the file anywhere. It's the simplest way to copy files to "nowhere."

Method 2: Periodically wiping files in your RAM Disk

If you need to simulate a more realistic file copy operation where files are momentarily "stored" before being deleted, you could set up a script to automatically delete files in your RAM disk at regular intervals or trigger the deletion through a specific event.

Here is a basic example of a batch script for Windows that deletes everything in a specified directory without prompting for confirmation:
del /Q /F R:\*
You'd need to replace R:\ with the actual path of your RAM disk. This script can be run manually, via a scheduled task, or triggered by an event (such as when the disk reaches a certain capacity).

Reply to this topic

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:

Email:

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: