Why would you want to take every file you have and delete its contents? Well if you have sensitive financial or proprietary data you know why. Deleting these files and even using shredding software sometimes allows for the data of these files to be recovered. However, one method of not allowing a file to be recovered is to open the file, modify the contents and delete the file.
Below, I will show you how to easily do that with a few lines of code in practically no time.
First, if you are a windows user, you will need cygwin to accomplish this. Otherwise, if you are a Linux user you can create and run script below.
- Open a text editor
- Type the following code in your text editor
for i in ls
cp /dev/null $i
- Save your file in the folder where you want to delete all files. Save the file without the .txt extension. If you are going to give your file an extension, give it an .sh extension.
- Open cygiwn and navigate to your file location. Provided that your file was name cleaner.sh, then type the following command in cygwin: ./cleaner.sh
That is it. You can open a window to that folder and view as the magic happen.
If you have any questions, post a comment. When I get an opportunity, i will post how to accomplish this same task using a windows batch file.