I added the possibility to create multiple empty files at once, just like folder creation where you write folders separated by semi-colon:
@var $n;
@var $file;
@var $file_name;
// Ask user for file name
@var $answer = AskText("Enter file name", "New file.txt", 0);
// If user canceled, abort
if ( $answer == 0 )
{
break;
}
@var $arr_files = StrTokenize2Array($answer, ";");
for( $n=0; $n<arrayCount($arr_files); $n++ )
{
$file = $arr_files[$n];
// Full path name
$file_name = GetSourcePath() ^ $file;
// If answer doesn't have any extension, default to .txt
@var $ext_size = StrLen( PathGetFileExtPart($file_name) );
if ($ext_size == 0)
{
$file_name = $file_name + ".txt";
}
// File exists?
if (FileExists($file_name) > 0)
{
MessageBox("Error", "File already exists. Stopping script.", 0);
break;
}
else
{
// Create empty file
SaveStringToFile($file_name, "", 0);
}
}
// Select created file
if( arrayCount($arr_files) == 1 )
{
// It's not possible to select the created file because the script doesn't recognize new items until the script ends. Only when it finishes is that new items are available and refreshed.
// But found a way using native CTRL+V feature
SetClipboardText($file_name);
MC.Explorer.Selection.UnselectAll
MC.RunCmd ID="Core.1312"
}