Count file and lgnore locked files

Toshiba Satellite l505d-s5965 notebook
April 14, 2010 at 06:12:10
Specs: Windows 7, 1024
Is it possible to count files lets say in the %temp% with subdirs and ignore the locked/being used files with out deleting them ?

See More: Count file and lgnore locked files

Report •


#1
April 14, 2010 at 10:35:20
you can get a count of locked files:
set locked=0
set files=0
for %%a in (*.*) do (
ren %%a %%a 2>nul
if errorlevel 1 (
set /a locked +=1
) else (
set /a files+=1
)
::-----
it's rather messy and inefficient. There's prob'ly a command somewhere that lists locked files but i couldn't find one offhand.

Report •

#2
April 14, 2010 at 14:35:34
well you get a different count when you

for /F %%j in ('dir "%Temp%" /a-d-h /b /s ^| find /C /V "*.*"') do set Count=%%j

and

del /s /f /q %temp% \*.* >>log.txt

i want the count thats from the DEL line but not delete then,


Report •

#3
April 14, 2010 at 17:07:11
have you tried attrib? it's good for that.
(attrib /s *.*)

Report •

Related Solutions

#4
April 14, 2010 at 19:35:31
How would that work?

no i havnt tried it.

im trying to find a way that works like the DEL >log.txt

and i want the line count for the log.txt but not delete them.

that may work but not sure how to set it up.


Report •

#5
April 14, 2010 at 21:09:47
pretty much just a swap-out for del, except for the switches:
@echo off & setlocal
for /f %%a in ('attrib /s %temp%' ^| find /v /c ""') do set xx=%%a
echo.count? is: %xx%

Report •

#6
April 14, 2010 at 21:24:39
for some reason the Code always echos 1 should be more than.

Report •

#7
April 14, 2010 at 22:41:11
if you cut/pasted, my apologies. errant sgl-quote in:
for /f %%a in ('attrib /s %temp%' ^| find /v /c ""') do set xx=%%a
should be thus:
for /f %%a in ('attrib /s %temp% ^| find /v /c ""') do set xx=%%a
::----
don't know if that's the whole issue, but def. pertinant, don't know how it didn't throw error...

Report •

#8
April 14, 2010 at 22:51:27
Still Counts the folder as '1'

count = 1 ? odd still same issue.


Report •

#9
April 14, 2010 at 23:19:23
I think it's the fact attrib is being passed only of dir name:

C:\Documents and Settings\judago>attrib /s %temp%
File not found - C:\DOCUME~1\judago\LOCALS~1\Temp

C:\Documents and Settings\judago>attrib /s %temp%\*
A          C:\DOCUME~1\judago\LOCALS~1\Temp\div7.tmp\div9.tmp

C:\Documents and Settings\judago>del /s /q %temp%
C:\DOCUME~1\judago\LOCALS~1\Temp\div7.tmp\div9.tmp
The process cannot access the file because it is being used by another process.

C:\Documents and Settings\judago>attrib /s %temp% | find /v /c ""
1

C:\Documents and Settings\judago>dir /a-d/s /b %temp%
C:\DOCUME~1\judago\LOCALS~1\Temp\div7.tmp\div9.tmp

C:\Documents and Settings\judago>


Report •

#10
April 14, 2010 at 23:48:58
@judago:
right on - i thought about doing pushd and running from there.
should have listened to my instincts. i think it will work owise.
hope this helps.
@echo off & setlocal
pushd %temp%
for /f %%a in ('attrib /s *.* ^| find /v /c ""') do set xx=%%a
echo.count? is: %xx%

Report •

#11
April 15, 2010 at 00:00:43
works great just what i needed.

thank you nbrane & Judago


Report •


Ask Question