Hi there.
I have a recurring task that is quite simple, but requires a lot of manual steps. I'm hoping to automate it.
On a network drive (which I do map), I have a file structure that looks like this:
PARENT FOLDER\
--TEXT\
--IMAGES\
--NATIVES\
I've been trying to write a script that does the following:
1. Generate a count of the files in each subfolder. I need seepage counts for each of the subfolders I've listed above.
2. Generate a list of filenames for the 0KB .txt files in the TEXT subfolder
3. Output to two text file reports, one with counts and the other a list of the 0kb text files by name only.
Each of the subfolders I listed above contains a series of subfolders (e.g. TEXT\01\ etc). So I need this script to be recursive and not include any of the subfolders in the counts or list of 0kb files.
Seems so simple, yet I can't seem to crack this.
Thanks!
Counting Classes of Files in Subfolder Hierarchy
Moderator: DosItHelp
Re: Counting Classes of Files in Subfolder Hierarchy
Save this file in PARENT FOLDER
Make sure there is no subfolder with name NULL in PARENT FOLDER.
Steffen
Code: Select all
@echo off &setlocal
>"count.txt" (
for %%i in ("TEXT" "IMAGES" "NATIVES") do (
for /f %%j in ('dir /a-d /b /s %%i 2^>nul^|find /c /v ""') do echo %%i %%j
)
)
>"zero.txt" (for /f "tokens=1*" %%i in ('robocopy "TEXT" NULL /l /s /ndl /xx /nc /njh /njs /fp /np') do if %%i==0 echo %%j)
Make sure there is no subfolder with name NULL in PARENT FOLDER.
Steffen
Re: Counting Classes of Files in Subfolder Hierarchy
Steffen,
Thank so much! That's fantastic.
Thank so much! That's fantastic.