| 1. |
Solve : batch for a multiple print job.? |
|
Answer» I know almost nothing about creating batch files. what happens if he wants to print rtf files or only certain files in a folder Change: dir /b *.txt | sort > alltext.txt to dir /b *.* | sort > alltext.txt or dir /b *.rtf | sort > alltext.txt or dir /b *.%1 | sort > alltext.txt After combining what I learned from your code snippets and http://ss64.com/nt/ I've come up with the following. The only problem I have is that the "list.txt" is included in the list of files and I'm not sure how to remove that as I don't want to print it and it's deleted after the FOR /F command processes. It's not so bad as it will print a list of things in the order they're supposed to be in and that might be useful for my application, but it's still superfluous and I'm a minimalist. also this doesn't require dragging and dropping. but it does require the batch to be given a hidden attribute Code: [Select]ECHO OFF ECHO Creating Directory Listing dir /a:-h /b /-p /o:EN >"list.txt" ECHO Processing Directory Listing FOR /F %%i IN ("list.txt") DO ( REM %%i notepad /p %%i ) ECHO Deleting Directory Listing del "list.txt" ECHO Process Complete. Press a key to exit. PAUSE Now, I don't have an ACTUAL printer to test this on. Only the windows XPS writer. Quote from: marylane on July 27, 2010, 04:04:37 PM Change: +1 fantastic. thanks a lot for the help. Quote from: ErusPrime on July 27, 2010, 04:18:27 PM The only problem I have is that the "list.txt" is included in the list of files and I'm not sure how to remove? findstr /V "list.txt" list.txt > list2.txt copy list2.txt list.txt del list2.txt For example: C:\test>type erus.bat Code: [Select]echo off echo Creating Directory Listing rem dir /a:-h /b /-p /o:EN >"list.txt" dir /b l*.txt > list.txt dir /b n*.txt >> list.txt findstr /v "list.txt" list.txt > list2.txt type list2.txt pause copy list2.txt list.txt del list2.txt echo type list.txt type list.txt pause ECHO Processing Directory Listing For /F %%i in (list.txt) do ( echo %%i rem notepad /p %%i ) ECHO Deleting Directory Listing rem del "list.txt" ECHO Process Complete. Press a key to exit. PAUSE Output: C:\test>erus.bat Creating Directory Listing log.txt nc.txt new.txt NextFile.txt notepid.txt num.txt Press any key to continue . . . 1 file(s) copied. type list.txt log.txt nc.txt new.txt NextFile.txt notepid.txt num.txt Press any key to continue . . . Processing Directory Listing log.txt nc.txt new.txt NextFile.txt notepid.txt num.txt Deleting Directory Listing Process Complete. Press a key to exit. Press any key to continue . . . C:\test>okay. I think that makes sense. I need all the files though and not just l*.txt and n*.txt are the pauses absolutely necessary? sometimes the list is going to be more than 100 lines long. or is that just a "look how it works" kinda thing? Quote from: ErusPrime on July 27, 2010, 07:16:16 PM okay. I think that makes sense. The pauses are not necessary. It was used while testing. I noticed your code got all files and also all directories. How do you print a directory with notepad? Also *.exe files will not print with notepad. I have never used may of the dir options in your batch file so I'm not sure what files you are after. I thought you were only after *.txt files? I'm not sure what this line does: dir /a:-h /b /-p /o:EN >"list.txt" It appears you get more files than needed? Good luck |
|