Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

For /f in (filename.txt) doesn't like spaces in line values - any help?

1,013 views
Skip to first unread message

.

unread,
May 19, 2010, 8:56:38 AM5/19/10
to
On Windows XP this is what I'm doing...

Make a batch file to manually scan a system drive,
currently ClamAV's gui doesn't do it, it only scans
for open files and running processes. My problem
is when the for loop reads the text file, if there's a space
in the text it only rads the first part, it hits the space
and goes to the next line.

My question - how can I have it read the full line including
the spaces? I've searched a bit but can't find the answer.
Hoping you batch file guru's can help me out ;-)

I'll give credit to whom credit is do oh great ones!

********************************************************************

:: Get a directory listing from the root system drive

%systemdrive%
cd\
dir /AD /B > dirs.txt

:: Now, lets scan with ClamAV all our directories

:: Change to ClamAV's Windows Directory

cd %ProgramFiles%\ClamAV for Windows\1.0.26"

for /f %%i in (c:\dirs.txt) do agent -d "%systemdrive%\%%i"

********************************************************************

dirs.txt file contents:

18051861446c3b9886
6541fd42d4b32dc25a13c9b65107
9b767b163a3212d9d2fd65bd
dell
Documents and Settings
drivers
i386
MSOCache
MySlaxTemp
NVIDIA
Program Files
RECYCLER
sysprep
System Volume Information
temp
WINDOWS

********************************************************************

ClamAV kicks off a scan just fine and dandy, it iterates through
each folder in the text file UNTIL it hits one with a space like
Program Files or Documents and Settings.

What I don't understand is I have it quoted but I don't think
it's my quotes, it seems to be a problem with how the command
line is reading the text file, it hits a space and moves to the next
line. Is there any way to have it read the whole line in the text
file?

Error output is this:

C:\Program Files\ClamAV for Windows\1.0.26>agent -d "C:\Documents"
May 19 08:58:20: ERROR: Scan::Directory: unable to open directory :
3 : The syst
em cannot find the path specified.


Thanks!

foxidrive

unread,
May 19, 2010, 9:01:34 AM5/19/10
to
On Wed, 19 May 2010 05:56:38 -0700 (PDT), "." <rfw...@gmail.com> wrote:

>Make a batch file to manually scan a system drive,
>currently ClamAV's gui doesn't do it, it only scans
>for open files and running processes.

>My question - how can I have it read the full line including
>the spaces? >

>********************************************************************


>
>:: Get a directory listing from the root system drive
>
>%systemdrive%
>cd\
>dir /AD /B > dirs.txt
>
>:: Now, lets scan with ClamAV all our directories

There should be no need to Change to ClamAV's Windows Directory

Try this:

set file="%ProgramFiles%\ClamAV for Windows\1.0.26\agent"

for /f "delims=" %%i in (c:\dirs.txt) do %file% -d "%systemdrive%\%%i"

The "delims=" sets the delimiter to nothing. It defaults to spaces and TABs.


--
Regards,
Mic

.

unread,
May 19, 2010, 9:24:01 AM5/19/10
to

Thanks Mic...that was BLAZINGLY fast!!!

That worked.

foxidrive

unread,
May 19, 2010, 9:40:32 AM5/19/10
to
On Wed, 19 May 2010 06:24:01 -0700 (PDT), "." <rfw...@gmail.com> wrote:

>> for /f "delims=" %%i in (c:\dirs.txt) do %file% -d "%systemdrive%\%%i"
>

>Thanks Mic...that was BLAZINGLY fast!!!
>That worked.

You're welcome.


If you also change that line above to this then it will work in any
folder you start with.

for /f "delims=" %%i in (c:\dirs.txt) do %file% -d "%%i"


--
Regards,
Mic

Teju Thejasvi

unread,
Jun 16, 2023, 1:54:41 AM6/16/23
to
Im appending test2 data by skipping the first row to test1 data but im having the files in a folder which uses space in its path. Please advice
set myPath="C:\Users\Documents\Test Folder"
for /F "skip=1 delims=" %%A IN (%myPath%\test2.dat") do (echo %%A)>> %myPath%\test1.dat
0 new messages