| Forum Home | ||||
| Press F1 | ||||
| Thread ID: 109067 | 2010-04-23 00:55:00 | Batch Script - For /f - Spaces in file path problem | jaketrsw (15733) | Press F1 |
| Post ID | Timestamp | Content | User | ||
| 879172 | 2010-04-23 00:55:00 | I am trying to use a vba script to batch print documents listed in at .txt file. The script works except when there is a space in the path of the .txt file that contains the list of documents to print. It returns an error saying it can't find the file. All the info I can find by trawling the forums says just put "" around the file path - but when I do this it prints the contents of the .txt file - not the documents themselves. Can anyone suggest a workaround for this problem? Is there any character I can put in in place of the space that will make it work? Here is my batch script: @echo off & setlocal for /f "delims=" %%a in (h:\my documents\printscript\testlist.txt) do ( "h:\my documents\printscript\Printdoc.vbs" "%%a" ) Pause NB: It works when there is no space in the .txt path, and it works when there are spaces in the file names of the documents its printing - just not when the .txt location has the spaces. |
jaketrsw (15733) | ||
| 879173 | 2010-04-23 01:17:00 | Should have added it to the other post (pressf1.co.nz) | Speedy Gonzales (78) | ||
| 879174 | 2010-04-23 01:23:00 | Thanks Speedy - its a different script and a different problem so I thought it could do with a different thread. Any Suggestions? |
jaketrsw (15733) | ||
| 879175 | 2010-04-23 01:31:00 | Its the same thing tho. Umm nope wouldnt have a clue. I dont use any commands to copy anything | Speedy Gonzales (78) | ||
| 879176 | 2010-04-23 02:47:00 | Use the "usebackq" option (from HELP FOR): usebackq - specifies that the new semantics are in force, where a back quoted string is executed as a command and a single quoted string is a literal string command and allows the use of double quotes to quote file names in filenameset. This requires strings (as opposed to file names) within the parentheses to have single quotes, not double quotes. Then all you have to do is quote the list file as follows: for /f "usebackq delims=" %%a in ("h:\my documents\printscript\testlist.txt") do ... |
MushHead (10626) | ||
| 879177 | 2010-04-23 02:54:00 | Excellent! That works perfectly. Thanks MushHead :-) |
jaketrsw (15733) | ||
| 1 | |||||