Easy way to make files 0 KB with a button?

Here's a quick and easy way to do it:

Truncate Files.dcf (1.3 KB)

To use the .dcf file, see the Button .dcf Files section of How to use buttons and scripts from this forum

Note that this has no undo. It truncates the files in-place, so you cannot undo it as the data is overwritten. A more complex script could send the old files to the recycle bin and then create new files where they were.

Script code that is in the .dcf file, for reference:

function OnClick(clickData)
{
	clickData.func.command.deselect = false;

	var fileCount = clickData.func.sourcetab.selected_files.count;
	if (fileCount == 0) return;
	var choice = clickData.func.Dlg.Request("Really truncate " + fileCount + " file" + (fileCount>1?"s":"") + "?\n\nThere is no undo!", "Truncate|Cancel", "Truncate Files");
	if (choice == 0) return;

	var tab = clickData.func.sourcetab
	for (var eSel = new Enumerator(clickData.func.sourcetab.selected_files); !eSel.atEnd(); eSel.moveNext())
	{
		var file = eSel.item().Open("wt", tab);
		file.Close();		
	}
}