Skip navigation

JSI Tip 1275. House cleaning user files.

You can generate a CSV (Comma Separated Value) file containing:

UserName of this files owner.
Full path file name.
Total bytes the user used on this "Drive".
Size of this file.
Last Access date of this file.
Last date this file was written.

JSIDskUse.bat uses DISKUSE and is run with the following syntax:

JSIDskUse RptFolder ID Drive1 \[Drive2 Drive3 ... DriveN\]     where:

RptFolder  is the full path to the folder that will contain JSIDskUse.CSV.

ID               is either the DomainName, or ComputerName you are reporting.

Drivex        is the Drive:, Folder Path, or UNC that you are reporting. I recommend using the UNC. Valid entry types are:


You may select multiple folders on each drive instead of the entire drive, multiple drives, and all your domain servers.

NOTE: JSIDskUse can obviously produce a large CSV and runs a long time.

NOTE: You must be a appropriatley priviledged to run this script.

NOTE: To report all files owned by Administrators, use an ID of BUILTIN.

JSIDskUse.bat contains:

@echo off
if "%3"

"" goto syntax if NOT "%1"

"" goto begin :syntax @echo Syntax: JSIDskUse RptFolder ID Drive1 \[Drive2 Drive3 ... DriveN\] endlocal goto end :begin set Folder=%1 set folder=%folder:"=%# set folder=%folder:\#=% set folder=%folder:#=% set /a cnt=0 if not exist %folder%\*.* goto syntax set Domain=%2 set Domain=%Domain:"=% shift if exist %Folder%\JSIDskUse.csv del /f /q %Folder%\JSIDskUse.csv :Drv shift if "%1"

"" goto finish set /a cnt=%cnt% + 1 set Drive=%1 set Drive=%Drive:"=% DiskUse %Drive% /f:%Folder%\JSIDskUse%cnt%.tm1 /e:%Folder%\JSIDskUse%cnt%.log /s /t /v /d:a set Found=N for /f "Skip=2 Tokens=*" %%i in (%folder%\JSIDskUse%cnt%.tm1) do call :parse "%%i" del /f /q %Folder%\JSIDskUse*.tm1 goto Drv :finish sort < %Folder%\JSIDskUse.tm2 > %Folder%\JSIDskUse.csv if exist %Folder%\JSIDskUse.tm2 del /f /q %Folder%\JSIDskUse.tm2 endlocal goto end :parse set data=%1 set byte=%data:~1,1% if "%byte%" LSS "0" goto fnd if "%byte%" GTR "9" goto fnd if not "%Found%"

"Y" goto end :output set data=%data:"=% set data=%data: =##% for /f "Tokens=1-3 Delims=, " %%i in ('@echo %data%') do set sz=%%i&set datea="%%j"&set file="%%k" set file=%file:##= % set datew= for /f "Skip=4 Tokens=1*" %%i in ('dir %file% /TW') do call :parse1 "%%i" @echo %Usern%,%file%,%Totsz%,%sz%,%datea%,%datew% >> %Folder%\JSIDskUse.tm2 goto end :parse1 if not "%datew%"

"" goto end set datew=%1 goto end :fnd set data=%data:"=% set data=%data: =##% for /f "Tokens=1-3 Delims=, " %%i in ('@echo %data%') do set ID="%%i" & set Usern="%%j" & set Totsz=%%k set ID=%ID:##= % set Usern=%Usern:##= % set Usern=%Usern:" ="% if /i not %ID%

"%Domain%" set Found=N&goto end set Found=Y :end

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.