Author Topic: Create empty text file  (Read 34279 times)

matm

  • Junior Member
  • **
  • Posts: 42
    • View Profile
Create empty text file
« on: May 14, 2012, 10:59:20 »
Hello

I have some use cases where i need to create empty text files. I would like to have a button/shortcut for that.
My workflow will be:
- Set the explorer panel in the folder
- Click the button
    * Create an empty text file and put it in rename mode, as it bahevaes currently when using right-click/New/Text Document
« Last Edit: May 16, 2012, 18:42:27 by matm »

Jungle

  • Contributor
  • VIP Member
  • *****
  • Posts: 542
  • Old Skull
    • View Profile
Re: Create emty text file
« Reply #1 on: May 14, 2012, 12:18:21 »
Maybe this script will be useful

Code: [Select]
@var $s = AskText("Enter file name", "New file.txt", 0);
$s = GetSourcePath() + $s;
SaveStringToFile($s, "", 0);

It asks you for the file name and then creates empty file. But if a file already exists, it will be overwritten.
« Last Edit: May 14, 2012, 12:51:51 by Jungle »

Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4423
    • View Profile
    • Multi Commander
Re: Create emty text file
« Reply #2 on: May 14, 2012, 12:51:38 »
Unfortunately I do not think there is a way I set the file into rename mode after that.

Calling one of the internal commands from script would solve that. I been planing to add something like that. I will see if I can add that in the next version.

If you just want to create an empty file you can also write "cf <filename>" in the commandline field. Then an empty file with the given name is created in the current location.



Jungle

  • Contributor
  • VIP Member
  • *****
  • Posts: 542
  • Old Skull
    • View Profile
Re: Create emty text file
« Reply #3 on: May 14, 2012, 12:56:59 »
Unfortunately I do not think there is a way I set the file into rename mode after that.

Maybe activating in-place rename is not possible, but another way is to use custom command

Code: [Select]
MC.Filesystem.Rename ASKNAME

matm

  • Junior Member
  • **
  • Posts: 42
    • View Profile
Re: Create empty text file
« Reply #4 on: May 16, 2012, 18:43:59 »
Thanks for all answers,
I will check that on Friday.

TY

duci

  • Junior Member
  • **
  • Posts: 25
    • View Profile
Re: Create empty text file
« Reply #5 on: May 21, 2012, 09:37:48 »
I wanted to post the same suggestion or question, where or how can I create an empty text file in MC. In my previous file manager it was possible with keys combination like SHIFT+F4 but here it doesn't work. This keys combination is very fast and useful. Do you plan to add something like that to next version of Multi Commander? The same is how to copy file into the same folder but with different file name. In my previous manager it was combination SHIFT+F5. These two options I used very often.

Thanks.

Dusan

Mathias (Author)

  • Administrator
  • VIP Member
  • *****
  • Posts: 4423
    • View Profile
    • Multi Commander
Re: Create empty text file
« Reply #6 on: May 21, 2012, 10:19:57 »
Shift+F5 (might be something other, depends on default style, men look in menu > file )
will copy the select file to the same folder and will suggest a name that is same as original with ".bak" appended

To create a empty file fast. You can type "cf <filname>" in the commandline field.

SKAN

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Create empty text file
« Reply #7 on: June 20, 2013, 13:51:47 »
I use the following script to create a new text file in active explorer panel:
However, I have to press F2 manually to rename it.
MC.RunCmd ID=ExplorerPanel.51002 seems to execute before MC.CmdLineRun can complete!.
Is MC.CmdLineRun ASYNCHRONOUS?

Code: [Select]
@var $File = "New";
@var $Ext  = ".txt";
@var $Part = $File + $Ext;
@var $Full = GetSourcePath() + $File + $Ext;

@var $nStr;
@var $n = 1;

while( $n > 0 )
{

   // Break loop if target filename does not exist

   if( GetFileTime( $Full ) == 0 )
     {
       break;
     }

   // Otherwise increment filename and loop

   $nStr = numtostr($n);
   $Part = $File + " [" + $nStr + "]" + $Ext;
   $Full = GetSourcePath() + $Part;
   $n++;
}

MC.Explorer.Selection.UnselectAll;
MC.CmdLineRun CMD="cf {$Part}";

// MC.RunCmd ID=ExplorerPanel.51002

Jungle

  • Contributor
  • VIP Member
  • *****
  • Posts: 542
  • Old Skull
    • View Profile
Re: Create empty text file
« Reply #8 on: June 20, 2013, 14:55:39 »
MC v3.2.0 supports creating new file (Shift+F4 by default) and it uses internal file associations.