How to empty all files in Folder (not delete)

anders.petersen

New Member
Hi

I would like to know how to empty all files in a folder and subfolders. By emptying, I do not mean to delete the files but to make them have a file size of 0 Kb.

I am working on a Mac, and I am thinking that there must a command to use in Terminal to do this. I have looked a little around, and found that the command: "cat /s /dev/null > filename" will do the trick, but only for one file at a time. And I need be able to clear all files in a folder + subfolders.

Any suggestions ?

Thanks

Anders
 
If you were familiar with any of the macro programs around (autoit, autohotkey etc) it would be quite easy.

Create an empty text file using Notepad.
Macro works through desired folder reading filename and saving the notepad file with the new filename (with steps to keep original empty file unchanged).

You may be able to do that with a batch file.

However, it's quite pointless if the file is anything other than a text file. If you do that with a jpg file, it's no longer a jpg because the header is gone. A Word document is no longer a Word document for the same reason. What is the intended goal?
 
Back
Top