Jump to content

Create several documents at once command line


bookie32

Recommended Posts


 

1 hour ago, bookie32 said:

Hi guys!

Instead of creating a batch file...

How do I create several files with differnt names at once....seen many how to's for directories but not actual documents?

 

bookie32

What do you mean? :w00t:

"Random" files? :dubbio:

https://www.digitalcitizen.life/3-ways-create-random-dummy-files-windows-given-size

or

http://www.bertel.de/software/rdfc/index-en.html

jaclaz

Link to comment
Share on other sites

Hi jaclaz:D

Yes...that can work.....

I was thinking on the lines of:

dir > text.txt text1.txt text2.txt

I just wondered how I could create several documents at once with just one line of code...

 

bookie32

Link to comment
Share on other sites

I will try again:

WHAT do you want to do?

You don't pay a fee per word posted, DESCRIBE in DETAIL what you need/want, otherwise you will only have people attempting to help you lose their time in guesses.

A one liner that creates an arbitrary number of  files (10 in this example, each containing the text "File" followed by the same progressive number that is also added to the filename) :

FOR /L %? IN (1,1,10) DO ECHO File%?>text%?.txt

jaclaz

 

Link to comment
Share on other sites

OK not following:

I cannot write the code as shown:

dir > text.txt text1.txt text2.txt

instead of writing:

dir > text.txt 

and then:

dir > text1.txt 

And so on...how do I write one line of code that creates all three files?

 

bookie32

Link to comment
Share on other sites

58 minutes ago, bookie32 said:

OK not following:

I cannot write the code as shown:

 

No. (You can actually "write the code as shown" but the result upon execution won't be three files).

1 hour ago, bookie32 said:

And so on...how do I write one line of code that creates all three files?

 

You can use a FOR /L loop, as shown.

Or, if you literally want three files called text.txt, text1.txt and text2.txt, all of them with the same content, the output of the command DIR:

dir>text.txt&dir>text1.txt&dir>text2.txt

almost the same result:

FOR /L %? IN (0,1,2) DO DIR>text%?.txt

actually the same result:

DIR>text.txt&FOR /L %? IN (1,1,2) DO COPY text.txt text%?.txt

jaclaz

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...