What command creates a file of specified type and size?

M

Mike Kaney

Hi all,

Was wondering if anyone knows the command in WinXP command shell to create
a file of a specified type and size? I have searched the internet and this
group, and found nothing. I know there is one because I have used it
before. Any help would be appreciated.


Mike
 
M

Mark V

In said:
Hi all,

Was wondering if anyone knows the command in WinXP command shell
to create
a file of a specified type and size? I have searched the internet
and this group, and found nothing. I know there is one because I
have used it before. Any help would be appreciated.

All I can suggest is
COPY CON filename.ext
(and F6 to close it)
This is a TEXT file and would like be .TXT, .BAT, .CMD or similar.

TYPE NUL >filename.ext
(create a zero-length file)

What is it you are actually trying to do?
 
M

Matthias Tacke

Mike Kaney said:
Hi all,

Was wondering if anyone knows the command in WinXP command shell to create
a file of a specified type and size? I have searched the internet and this
group, and found nothing. I know there is one because I have used it
before. Any help would be appreciated.
I remeber also such command, but not as an integrated in XP. It was
a tool to create diskfiles for harddisk tests.

You can create files with defined size by using some for loops and
appending output to a file.
Keep in mind that you can create a file with any name and extension but
some filetypes require an inner structure which you can't easily/at all
resemble this way.

To start with the for command for /?

FOR /L %Variable IN (Start,Step,End) DO command [parameters]

=========creatfil.cmd============
@echo off & setlocal enableextensions
:: expects 3 parameters filename, blocksize, numblocks (no testing)
set fil=%1
:: to keep it simple we will echo 30 chars per line plus two cr/lf
:: so blocksize 32 gives one Kilobyte with 1024 byte
set blocksize=%2
:: block size in extends of 32
set numblocks=%3
:: number of blocks to generate
del %fil%
for /L %%A IN (1,1,%numblocks%) do (
for /L %%B IN (1,1,%blocksize%) do (
echo/123456789012345678901234567890>>%fil%))
dir %fil%
====================================
 
M

Matthias Tacke

:
The del statement in my example is a bit dangerous, when mistakingly
entering an important file. Please change it to the following
To start with the for command for /?

FOR /L %Variable IN (Start,Step,End) DO command [parameters]

=========creatfil.cmd============
@echo off & setlocal enableextensions
:: expects 3 parameters filename, blocksize, numblocks (no testing)
set fil=%1
:: to keep it simple we will echo 30 chars per line plus two cr/lf
:: so blocksize 32 gives one Kilobyte with 1024 byte
set blocksize=%2
:: block size in extends of 32
set numblocks=%3
:: number of blocks to generate
del %fil%
if exist %fil% echo Attention file %fil% exists !!! & goto :eof
 
D

Dean Wells [MVP]

Mike said:
Hi all,

Was wondering if anyone knows the command in WinXP command shell to
create a file of a specified type and size? I have searched the
internet and this group, and found nothing. I know there is one
because I have used it before. Any help would be appreciated.


Mike

The following command will create a ~100MB sparse file named \foo.txt -

fsutil file createnew \foo.txt 100000000

NOTE - Since you did not specify the purpose of the file I cannot
determine if a sparse file will suffice ... with any luck, this will do
the job.

Dean
 
M

Mike Kaney

Dean Wells said:
Mike said:
Hi all,

Was wondering if anyone knows the command in WinXP command shell to
create a file of a specified type and size? I have searched the
internet and this group, and found nothing. I know there is one
because I have used it before. Any help would be appreciated.


Mike

The following command will create a ~100MB sparse file named \foo.txt -

fsutil file createnew \foo.txt 100000000

NOTE - Since you did not specify the purpose of the file I cannot
determine if a sparse file will suffice ... with any luck, this will do
the job.

Dean

--
Dean Wells [MVP / Windows platform]
MSEtechnology
[[ Please respond to the Newsgroup only regarding posts ]]
R e m o v e t h e m a s k t o s e n d e m a i l
Dean,

I remember it being even less complicated, but that will be perfect. I
mainly wanted to use it to create files to bloat my inbox at yahoo and such
so that it will bounce email and perhaps reduce some of my spam. I am sure
I can find other uses for it as well. I am sure it wasn't intended for
those purposes, but what the hey. Thanks again.



Mike
 
R

Radhakrishnan

Hi,

I need a advice from you, can we create batch script which
can create a file in system date in this format
"Date-Day-Month-Year.txt"

Please advice me. This will be really usefull for me.

Do send me your mail to (e-mail address removed). so
that it can reach my desk.

Thanks & Regards,

Radhakrishnan.K

([email protected])
-----Original Message-----
Mike said:
Hi all,

Was wondering if anyone knows the command in WinXP command shell to
create a file of a specified type and size? I have searched the
internet and this group, and found nothing. I know there is one
because I have used it before. Any help would be appreciated.


Mike

The following command will create a ~100MB sparse file named \foo.txt -

fsutil file createnew \foo.txt 100000000

NOTE - Since you did not specify the purpose of the file I cannot
determine if a sparse file will suffice ... with any luck, this will do
the job.

Dean

--
Dean Wells [MVP / Windows platform]
MSEtechnology
[[ Please respond to the Newsgroup only regarding posts ]]
R e m o v e t h e m a s k t o s e n d e m a i l


.
 
P

Phil Robyn

Radhakrishnan said:
Hi,

I need a advice from you, can we create batch script which
can create a file in system date in this format
"Date-Day-Month-Year.txt"

Please advice me. This will be really usefull for me.

for /f "tokens=1-4 delims=/ " %%a in (
"%date%"
) do set day=%%a&mm=%%b&set dd=%%c&set yyyy=%%d
set filename=%dd%-%day%-%mm%-%yyyy%
set better=%yyyy%-%mm%-%dd%-%day%
set filename
echo/But if you use %better% you will be better off.
Do send me your mail to (e-mail address removed). so
that it can reach my desk.

No, you will have to check the newsgroup for an answer.
Thanks & Regards,

Radhakrishnan.K

([email protected])

-----Original Message-----

command shell to

searched the

there is one
appreciated.


The following command will create a ~100MB sparse file

named \foo.txt -
fsutil file createnew \foo.txt 100000000

NOTE - Since you did not specify the purpose of the file

I cannot
determine if a sparse file will suffice ... with any

luck, this will do
the job.

Dean

--
Dean Wells [MVP / Windows platform]
MSEtechnology
[[ Please respond to the Newsgroup only regarding posts ]]
R e m o v e t h e m a s k t o s e n d e m

a i l
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top