Open-Print-Close Notepad Text files within a directory

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
chubster
Posts: 3
Joined: 09 Sep 2014 16:31

Open-Print-Close Notepad Text files within a directory

#1 Post by chubster » 09 Sep 2014 16:38

Hi,
I'm new to writing batch files and looking for some help with the following:

I have a directory with 10 notepad text files and would like to:
1) Open File
2) Print File
3) Close File
4) Repeat 1 thru 3 until all 10 text files in directory are printed.

Thank you,
Chubs


chubster
Posts: 3
Joined: 09 Sep 2014 16:31

Re: Open-Print-Close Notepad Text files within a directory

#3 Post by chubster » 09 Sep 2014 16:51

Thanks.
I guess I don't understand how Notepad /P will print all 10 files.
Do I execute the cmd in the directory?

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Open-Print-Close Notepad Text files within a directory

#4 Post by Squashman » 09 Sep 2014 17:28

Well the long hand way.

Code: Select all

notepad /p file1.txt
Notepad /p file2.txt
Notepad /p file3.txt

Etc......

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Open-Print-Close Notepad Text files within a directory

#5 Post by Squashman » 09 Sep 2014 17:37

The more dynamic way.

Code: Select all

for %%G in (*.txt) do notepad /p "%%G"

chubster
Posts: 3
Joined: 09 Sep 2014 16:31

Re: Open-Print-Close Notepad Text files within a directory

#6 Post by chubster » 09 Sep 2014 18:32

Thanks Squashman.
All responses extremely helpful.
This solved my query.

Regards,
Chubs

Post Reply