Here is the situation, I have directories that have 10,000 files in each directory named like this:
FilesNAME.XX0000.csv
FilesNAME.XX9999.csv
The Size of the filename itself can change ie:
FilesNAME.XXX0000.csv
FilesNAME.XXX9999.csv
FilesNAME.XXXX0000.csv
FilesNAME.XXXX9999.csv
Where the X's are yet another parent number, but these ones should be ignored anyway.
Regardless though all directories are supposed to have exactly 10,000 files no more and no less. The trouble is some are missing and I need to know which ones are missing. Now I already have a script I use to count the files in sub directories and print the list to file. Then I manually move those folders to an Incomplete folder for further investigation to determine which file names are missing.
I need to come up with a solution that will easily tell me which numbers or file names are missing in the sequence. In my Dream world I would love a script where I can place it inside a parent directory and it would crawl through all the sub directories and print a single file of the missing ones.
It would be nice to not have to tell the script what the beginning part of the file name is, since in theory it should only be looking to see if the last four numbers are in existance from 0000-9999.
Find missing sequential file names
Moderator: DosItHelp
Re: Find missing sequential file names
This should do it from a parent folder. Untested:
It should write the log file in the folder it is executed in.
It should write the log file in the folder it is executed in.
Code: Select all
@echo off
setlocal enabledelayedexpansion
set "log=%cd%\logfile.txt"
for /f "delims=" %%a in ('dir /ad /b /s') do (
pushd "%%a"
for /L %%b in (10000,1,19999) do (
set a=%%b
set a=!a:~-4!
if not exist "*!a!.csv" >>"%log%" echo "%%a - *!a!.csv"
)
popd
)
Re: Find missing sequential file names


I was looking for some way to list all missing files in folders containing numbered (sequenced) image files and this is perfect
one thing, what would I have to change to make it work INSIDE a folder (and that it prints logfile inside that same folder?)
I wonder if Data9er solved their problem?
Re: Find missing sequential file names
warthog wrote:one thing, what would I have to change to make it work INSIDE a folder (and that it prints logfile inside that same folder?)
Just remove the %cd%\ part of set "log=%cd%\logfile.txt"
Thanks for the correction too - I have edited my post above. Glad it was useful for you.