Option to automatically delete files copied to RAM Disk

2 posts · Closed

Claus Guest
19 Mar 2024

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

I just want to have a folder 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 Disk 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?

Andrew SoftPerfect
19 Mar 2024

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).

This topic is closed. It has had no new posts for over a year, so the software versions it talks about may be out of date. Start a new topic in RAM Disk if you have a similar question.