1.

Solve : for?

Answer»

When I do a forloop this one

Code: [Select]for /f "skip=%dirs%" %%a in ('dir /b /o:g') do set dirf=%%a
it only displays one line
this is the whole script


Code: [Select]@echo off
:start
for /f "tokens=1 delims= " %%a in ('dir *.* ^| find /i "Dir(s)"') do set dirs=%%a
echo %dirs%
pause
for /f "skip=%dirs%" %%a in ('dir /b /o:g') do set dirf=%%a
echo %dirf%
pause




This is because each time around the loop you are setting the dirf variable to the current value of the looping variable, therefore it will only ever HOLD the last line.

Grahamso what can i do to get all of the linesCode: [Select]@echo off
:start
for /f "tokens=1 delims= " %%a in ('dir *.* ^| find /i "Dir(s)"') do set dirs=%%a
echo %dirs%
pause
for /f "skip=%dirs%" %%a in ('dir /b /o:g') do echo %%a
pause

Naturally the list will be missing the items you skipped.

8-)Here is another problem if you run it on the DESKTOP when it cheaks for the # of dirs it will include the systom ones (like: My computer and My network places) then when it does the BEAR display (dir /b *.*) it will not display the system folders so it will skip to manny lines taking out some of the files. Any idea on what to do. :-? :-?Which way do you want it to work?never mind that i have know idea what the dirs at the top are when i use it on my desktop dir named "." and another named ".." show up when i do dir *.* and do not show up if i do dir /b *.*
The "." and ".." are implied for all subdirectories.
. = current directory
.. = parent directory

Here are some tips that MAY help shorten THINGS up for you:

To count the number of directories including hidden and system, use:
dir /b /ad |find /v /c "*"

To count the number of directories including hidden (but including system), use:
dir /b /a:d-h |find /v /c "*"

To count the number of directories excluding hidden and system, use:
dir /b /a:d-h-s |find /v /c "*"
ok i will mess with that think you



Discussion

No Comment Found