I've brought up needing to make empty files before by generating them on the second side of the Lister but this has caused so much confusion of which files go where and it has in general wasted so much time and I'm not sure if all the files are in the right spot at this point. Sorry for the long sentence
Is there an easy way to make a button that can do this? Maybe a button that copies the selected files names, deletes the files, then recreates them with the names it saved?
Which do you want to do, create the empty files over the top of the selected files? Or create empty files in the destination with the same names as the selected files in the source? Or something else?
What about folders, or files in folders, if they are selected?
I'm trying to replace the selected files in the current folder with empty ones with the same names. I'm doing this so i can get rid of the files without certain programs regenerating them. I only need to replace files in the current folder and not subfolders. If it this is possible and it doesn't require any extra time or work it would also be useful if the files could be marked with the hidden and system attributes.
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();
}
}
Could I get a version of this without the popup? I wouldn't click the button accidentally and I use it quite a lot so it would make things a lot easier.