How To Erase A Folder's Contents With A Batch File

Lifeblood

New Member
I am using Eraser version 5.86.1.

I wrote the batch script below which allows me to erase the Recycle Bin with the single-pass random data method, just by clicking on it.

@echo off


:: CLEARS RECYCLE BIN WITH 1 PASS OF PSEUDORANDOM DATA

start "" "C:\Program Files\Heidi.ie\Eraser\eraserl.exe" -recycled -method Random 1


exit

My question is how do I modify this so I can erase the contents of a specific folder?

For example say I want to delete the contents of a folder on my Desktop named Trash, but leave the folder itself.

How would I invoke eraserl.exe to go to the path "C:\Documents and Settings\Owner\Desktop\Trash", delete the contents, and then leave the folder named Trash empty on the Desktop?

I tried this:

start "" "C:\Program Files\Heidi.ie\Eraser\eraserl.exe" "C:\Documents and Settings\Owner\Desktop\Trash" -subfolders -keepfolder -method Random 1

thinking it would start eraserl.exe, point to the Trash folder, then apply the proper parameters, but it didn't work. And before I accidentally delete something important I decided to ask for help.

My problem is that I just don't know the syntax for the command. The help screen that I see when I click on eraserl.exe for the command line parameters isn't all that clear to me.

If you could, please explain the variety of ways a folder's contents may be erased. For example, how to erase everything including the top folder, or how to erase all contents, but leave the top folder, or how to erase just subfolders, or how to erase just files, but leaving subfolders and the top folder, etc.

Please help.

Thanks
 

Joel

Active Member
Sorry, I was busy setting up Trac on a new server for Eraser. I should disclaim that Eraser 5 is no longer officially supported -- but I'll help to the best I can.

Lifeblood said:
For example say I want to delete the contents of a folder on my Desktop named Trash, but leave the folder itself.

How would I invoke eraserl.exe to go to the path "C:\Documents and Settings\Owner\Desktop\Trash", delete the contents, and then leave the folder named Trash empty on the Desktop?

I tried this:

start "" "C:\Program Files\Heidi.ie\Eraser\eraserl.exe" "C:\Documents and Settings\Owner\Desktop\Trash" -subfolders -keepfolder -method Random 1
I don't have a v5 binary around, but reading the source code, I'd think you need a -folder:
Code:
start "C:\Program Files\Heidi.ie\Eraser\eraserl.exe" -folder "C:\Documents and Settings\Owner\Desktop\Trash" -subfolders -keepfolder -method Random 1
Lifeblood said:
My problem is that I just don't know the syntax for the command. The help screen that I see when I click on eraserl.exe for the command line parameters isn't all that clear to me.
Don't worry, in v6 it's not clear, in 6.2 it's a work-in-progress but that too seems to be rather unintuitive.

Lifeblood said:
If you could, please explain the variety of ways a folder's contents may be erased. For example, how to erase everything including the top folder, or how to erase all contents, but leave the top folder, or how to erase just subfolders, or how to erase just files, but leaving subfolders and the top folder, etc.
I was rationalising about this a while back and Eraser definitely does not handle subfolders well. I can however imagine that it can be broken down to these few scenarios:

  • Erase the folder, subfolders and all files
  • Erase the folder, subfolders, and all files, leaving the folder alone
  • Erase the folder, and all files (including files in subfolders), leaving all folders alone (Eraser 6 does this)
  • Erase the folder, all files in the folder, but leave subfolders alone
Are there any other permutations?
 

Joel

Active Member
Top