Closed Thread Icon

Topic awaiting preservation: Putting mulitple files in array - DOS (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=26460" title="Pages that link to Topic awaiting preservation: Putting mulitple files in array - DOS (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Putting mulitple files in array - DOS <span class="small">(Page 1 of 1)</span>\

 
CPrompt
Maniac (V) Inmate

From: there...no..there.....
Insane since: May 2001

posted posted 08-16-2005 00:28

I need to some funky stuff using a batch file in DOS and need some help. Here is what I need to do

I have a directory that has a bunch of files in it. I need to loop through this directory and put each file in an array to be printed. I need to use the lpr command to print the files but it will be a random amount of files and never have the same names. So here is what I was going to try:

code:
FORFILES -pC:\MyFolder -m*.PDF -clpr -S 192.168.1.50 -P 2075



but this isn't really working and I know why. The lpr command has to be done like:

code:
lpr -S 192.168.1.50 -P 2075 "myfile.PDF"



It has to have the file that is going to be printed put at the end in quotes. So...I need to loop through the folder, grab the file names, put them in an array and then do the lpr command with the array name in quotes. However, I am now at a loss as to how to get the files in an array.

Any and all help would be appreciated!

Later,

C:\

lallous
Maniac (V) Inmate

From: Lebanon
Insane since: May 2001

posted posted 08-16-2005 11:04

Hello CPrompt,

Try something like this:

code:
rem save current directory
pushd .
cd YOURTARGET_DIR

rem use command on each file
for %a in (*.pdf) do lpr -S 192.168.1.50 -P 2075 %a

rem restore old directory
popd



--
Regards,
Elias

CPrompt
Maniac (V) Inmate

From: there...no..there.....
Insane since: May 2001

posted posted 08-16-2005 12:19

Hey lallous. Thanks. I will give that a go. Much more simple than some of the things I was trying

Thanks!

Later,

C:\

CPrompt
Maniac (V) Inmate

From: there...no..there.....
Insane since: May 2001

posted posted 08-16-2005 14:33

Worked like a charm. I actually just changed one thing. On the variable it needs 2 %'s
So,

code:
FOR %%a IN (*.txt) DO lpr -S 192.1.50.206 -P 3800 %%a



was really all I needed.

THANKS!

Later,

C:\

lallous
Maniac (V) Inmate

From: Lebanon
Insane since: May 2001

posted posted 08-16-2005 14:53

Yes true, if you are to use it in a batch file you have to use '%%' but if you want to use it from command line you use only one '%'

Glad that it worked!

--
Regards,
Elias

« BackwardsOnwards »

Show Forum Drop Down Menu