DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: DONE: Search Subdirs for Missing File  (Read 8,500 times)

edbro

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 426
DONE: Search Subdirs for Missing File
« on: January 19, 2010, 01:28 AM »
I need the capability to search a directory that has a lot of subdirectories and find those subdirs that are missing a certain file. I'd like to be able to run a search and be able to see which folders are missing a filename that I can supply as an argument.

Target

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 1,840
    • Coding Snacks
Re: DONE: Search Subdirs for Missing File
« Reply #1 on: January 19, 2010, 03:43 AM »
try this AHK code...

you will be prompted for a starting directory and a filter file

script will search through and display a list of offending folders in a small gui (list)

note that I have assumed that each folder should be considered in isolation, ie a folder that doesn't contain the selected file but does contain a subfolder containing it is still considered to NOT contain the file  

nothing fancy, but it should get you started

Code

loop, parse, a_loopfilefullpath
{
    if a_loopfield = \
        L1++
}   

loop, %source%\*.*, 2, 1
{
    error = 0
    loop, %a_loopfilefullpath%\%myVAR%, 0, 0
    {
            error:= 1
            Break
    }
    if error = 0 
        mylist.= a_loopfilefullpath . "`n"
}

sort, mylist, CL U

menu, print, add, Print
menu, ToFile, add, To_File
;menu, ToHTML, add, To_HTML
menu, menubar, add, print
menu, menubar, add, To_File
;menu, menubar, add, To_HTML
gui, menu, menubar
gui, add, listview, r20 w750 grid nosort gClickMe, Folder
loop, parse, mylist, `n
{
    lv_ADD("",a_loopfield)
}
gui, add, statusbar,, source folder - %source%
gui, show
return

guiescape:
guiclose:
exitapp

print:
fileappend, %mylist%, c:\temp\Tmp.txt
runwait, print c:\temp\Tmp.txt,,hide
filedelete, c:\temp\Tmp.txt
return

to_file:
filedelete, %source%\ex-files.txt
fileappend, %mylist%, %source%\ex-files.txt 
return

ClickMe:
if a_guievent = DoubleClick
{
    lv_GetText(myFolder,A_eventinfo)
    run %myfolder%
}
return

#r::reload

EDIT: updated source
Alcohol is photoshop, bottled
Askhole - someone who ask for advice, then ignores it
"Look wise, say nothing, and grunt. Speech was given to conceal thought" - Sir William Osler
« Last Edit: January 22, 2010, 02:32 AM by Target »

skwire

  • I eat Coding Snacks for breakfast...
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,297
    • Participated in NANY Challenge Seventeen Times
    • Coding Snacks
    • Superboy Coder
    • Cody Award
    • Volunteers/Staff
    • Gathering Badge
Re: DONE: Search Subdirs for Missing File
« Reply #2 on: January 19, 2010, 04:47 AM »
Here's my take (source/binary included): Download

2010-01-18_224513.png

Target

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 1,840
    • Coding Snacks
Re: DONE: Search Subdirs for Missing File
« Reply #3 on: January 19, 2010, 06:25 AM »
a small improvement - added the functionality to print the list, or export it to a file

EDIT: redundant attachments removed
Alcohol is photoshop, bottled
Askhole - someone who ask for advice, then ignores it
"Look wise, say nothing, and grunt. Speech was given to conceal thought" - Sir William Osler
« Last Edit: January 22, 2010, 02:33 AM by Target »

Target

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 1,840
    • Coding Snacks
Re: DONE: Search Subdirs for Missing File
« Reply #4 on: January 20, 2010, 01:27 AM »
a further change - double click an entry in the list to open that folder in exploder

Alcohol is photoshop, bottled
Askhole - someone who ask for advice, then ignores it
"Look wise, say nothing, and grunt. Speech was given to conceal thought" - Sir William Osler
« Last Edit: January 22, 2010, 02:34 AM by Target »

Original address: https://www.donationcoder.com/forum/index.php?topic=21414.0