Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I'm not sure if this is a parsing problem or not, but I would appreciate help. My fingers are bleeding from goolgle searches on the problem.
I'm trying to list processes with full path in windows xp home and pro. Pv.exe does give the full path, but with spaces. I used tokens=1, etc. and can list all of the process paths, no matter how many spaces in the path.
C:\Program Files\Symantec\Norton Ghost\Agent\PQV2iSvc.exe
However, to actually use the path to process files, I have to put quotes around them. so I tried (list from filepath.txt):
for /f "tokens=1,2 delims=" %%a in (filepath.txt) do echo "%%a">>path.txt
and I get:
"C:\Program Files\Symantec\Norton Ghost\Agent\PQV2iSvc.exe "The spaces after .exe are not all in the same place, but there are spaces after every exe. I don't know how to get rid of them. Can someone help?
Mark

Take a look at this bat. If we're on the right track, we can hammer out the rest.
::== nospace.bat
@echo offecho C:\Program Files\Symantec\Norton Ghost\Agent\PQV2iSvc.exe > filepath.txt
for /f "tokens=*" %%a in (filepath.txt) do echo %%a
for /f "tokens=*" %%a in (filepath.txt) do call :sub1 %%a
goto :eof:sub1
echo %1%2%3%4%5%6%7%8%9 > nospace.txt
goto :eof
:: DONE
=====================================
If at first you don't succeed, you're about average.M2Go

I appreciate the response. Your solution works great on paths with no spaces except the ones at the end, but for directories like \Norton Ghost\ or \Program Files\, the spaces need to be there for the path to be valid. Since what I want to do process the file at the end of the path - no matter what is it -, I don't see how this could work considering all the possible variables. Any ideas?
Mark

The following slightly modified code from the native M2's one achieves what you wish
@Echo Off
For /f "tokens=* delims=" %%a in (filepath.txt) Do Call :NORM %%a
GoTo :EOF:NORM
Echo "%*" >> Path.txt
GoTo :EOFwhere Call :NORM %%a fits the line starting with For (no CR/LF between).

Thanks, IVO
=====================================
If at first you don't succeed, you're about average.M2Go

Beautiful. I thank both of you. I'm never motivated to learn anything until I need it. I
appreciate your knowledge.Mark

Ok I have a slightly different and probably A-LOT-easier-to-solve problem. I'm trying to extract JUST the PID (process ID) from a .txt file who's output comes from pslist.exe. Keep in mind I know close to zero about batch files and ANY general programming/script writing!
pslist.exe > list.txt
next I use FIND "ctfmon" list.txt >listp.txtThe result is a line that looks like this:
---------- LIST.TXT
ctfmon 4016 8 1 67 1012 0:00:00.100 0:15:21.394ALL I WANT is that PID (4016) clean and pure, so I can store it a variable for later use by another program. Any ideas? I'm sure this complex crap i'm tearing the a$$ out of myself to do can be done like in one line. I know I suck but hey, thats life.

Try this:
for /f "tokens=2" %%T in (list.txt) do set myvar=%%T
If at first you don't succeed, you're about average.M2

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |