[Date Prev][Date Next][Subject Prev][Subject Next][Date Index][Subject Index]

Creating a new file in Windows and XyWrite



How do you create a new file at the Windows command prompt? One way is to issue the command
"ECHO ON" (or "ECHO OFF") and redirect the output to a file. Since the output of
either command is null, a zero-byte file is written to disk. The filename can, of course, be of the
8.3 variety or a long filename. So:

echo on > X:\myfile.txt
echo on > X:\my-long-filename.txt
echo on > "X:\my long filename.txt"

produces three empty files:

05/29/2024  12:56 AM                 0 MYLONG~1.TXT my long filename.txt
05/29/2024  12:56 AM                 0 MY-LON~1.TXT my-long-filename.txt
05/29/2024  12:55 AM                 0              myfile.txt

Great. Can we do the same thing from the XyWrite command line? Sure:

dos[/nv/x/z] /c cmd.exe /c echo on > X:\myfile.txt
dos[/nv/x/z] /c cmd.exe /c echo on > X:\my-long-filename.txt
dos[/nv/x/z] /c cmd.exe /c echo on > "X:\my long filename.txt"

You get a briefly-flashing cmd.exe window with each command, but the result is the same:

05/29/2024  01:00 AM                 0 MYLONG~1.TXT my long filename.txt
05/29/2024  01:01 AM                 0 MY-LON~1.TXT my-long-filename.txt
05/29/2024  01:02 AM                 0              myfile.txt

Can the XyWrite command be refined to something simpler and more user-friendly? Well, with the
Winstart facility that I posted about earlier this month (<http://xywrite.org/mail/msg43699.html>), it can.
The commands become (and now there is no flashing cmd.exe window):

start echo on > X:\myfile.txt<Helpkey>
start echo on > X:\my-long-filename.txt<Helpkey>
start echo on > "X:\my long filename.txt"<Helpkey>

Again, same result in Windows:

05/29/2024  01:10 AM                 0 MYLONG~1.TXT my long filename.txt
05/29/2024  01:10 AM                 0 MY-LON~1.TXT my-long-filename.txt
05/29/2024  01:10 AM                 0              myfile.txt

More to the point, XyWrite will now give you a DIR listing with the resulting 8.3 filenames:

MYLONG~1  TXT           0     5-29-2024   1:10am 
MY-LON~1  TXT           0     5-29-2024   1:10am 
MYFILE    TXT           0     5-29-2024   1:10am 

And, of course, by CAlling these files as you would any other, they can be edited in XyWrite.

The same approach applies to other commands, of course. Want to create a directory with a long name?

dos[/nv/x/z] /c cmd.exe /c mkdir "X:\my long directory"
- or -
start mkdir "X:\my long directory"<Helpkey>

Result in Windows:

 Directory of X:\

05/29/2024  01:18 AM    <DIR>          MYLONG~1     my long directory

Result in XyWrite:

MYLONG~1     ®MDBO¯<DIR>®MDNM¯            5-29-2024   1:18am 

And that's about it for now.

-- 
Carl Distefano
cld@xxxxxxxxxx