Help - Search - Members - Calendar
Full Version: finding folders *without* specified files
Hydrogenaudio Forums > Misc. > Off-Topic
mazy
hello,

i need a way to find folders under given path that do not contain specified files, like *.nfo, *.xml.tags (my custom format) etc.

it would be best if the results could have been drag'n'dropped. also special features like 'consider only bottom-level folders', 'consider only non-empty folders' etc. would be nice ...

util or some sort of script would do ... for win32
rutra80
I guess it could be done with regular expressions, Total Commander can search with them.
RedFox
QUOTE(mazy @ Apr 20 2005, 11:52 AM)
i need a way to find folders under given path that do not contain specified files, like *.nfo, *.xml.tags (my custom format) etc.
*


A)Not exactly what you're looking for, but Treesize Professional (http://www.jam-software.com/treesize/, Shareware) is a diskspace manager with an extension filter feature: you can filter on one extension so the reports (incl. nb of files) you will see, will be only for the extension you selected.

B)In a script, eg:
dir *.htm? *.txt /s | grep R.pertoire
This will give you a list of folders (absolute paths) containing at least one file matching *.htm? or *.txt
1) change "R.pertoire" with something like "folder" if you're using a US version
2) grep for Windows is part of GNU Utils (http://unxutils.sourceforge.net/)

I don't know about extracting the list of bottom-level folders, sorry. sad.gif

kwanbis
ok ... here you have it ... very basic ... Not Here 0.1 ....

C:\DEV\nothere>nothere . file_id.diz
NotHere 0.1 by Kwanbis - Developed in Borland Delphi.
Parameters: C:\DEV\nothere\nothere.exe.file_id.diz

NOT Found file_id.diz in <C:\DEV\nothere>
NOT Found file_id.diz in <C:\DEV\nothere\a>
NOT Found file_id.diz in <C:\DEV\nothere\a\a1>
NOT Found file_id.diz in <C:\DEV\nothere\a\a2>
NOT Found file_id.diz in <C:\DEV\nothere\b>
NOT Found file_id.diz in <C:\DEV\nothere\b\b1>
NOT Found file_id.diz in <C:\DEV\nothere\c>
NOT Found file_id.diz in <C:\DEV\nothere\c\c1>
NOT Found file_id.diz in <C:\DEV\nothere\c\c2>
NOT Found file_id.diz in <C:\DEV\nothere\c\c2\c2a>
NOT Found file_id.diz in <C:\DEV\nothere\c\c2\c2b>
NOT Found file_id.diz in <C:\DEV\nothere\c\c2\c2c>
NOT Found file_id.diz in <C:\DEV\nothere\c\c3>
DONE. Press <ENTER> to finish.
mazy
thanks for your help, guys!

kwanbis, that's very nice that you made that ... i would like to see some advanced features:

1) filemasks (i.e. *.xml, *.nfo)
2) switch to limit reporting only to
a) non-empty folders (i.e. without files but possibly with subfolders)
b) folders with specified types of files (it should support multiple masks)
3) that's difficult one - i need to get resulting list as imput to other app (in this case foobar), so i would need it to support drag'n'drop (which i'm not sure is possible in console app). also param to make the output 'clear' (only list of dirs, without any additional info / formatting) could help ...

i would use option 2) this way: *.mp3,*.flac,*.ogg ... so i could find folders with music files, which do not contain in my case *.tag.xml file ...

could you share your sources? i've done some delphi coding in the past and would like to try again wink.gif
kwanbis
QUOTE(mazy @ May 1 2005, 06:32 PM)
could you share your sources? i've done some delphi coding in the past and would like to try again wink.gif

it was a really quick hack wink.gif ... here are the sources ... unde the GPL license:

CODE
// NotHere - Copyright Kwanbis - License GPL
program nothere;


{$APPTYPE CONSOLE}

uses
 SysUtils;

Procedure Directorio(StartDir: AnsiString; Archivo: AnsiString);
var DirInfo: TSearchRec; r: Integer; found: boolean;
begin
//  Writeln('Processing Directory: <' + StartDir + '>');
 found := false;
 SetCurrentDir(StartDir);
 r := FindFirst(StartDir + '\*.*', FaDirectory, DirInfo);
 while r = 0 do  begin
   if UpperCase(DirInfo.Name) = UpperCase(archivo) then Found := True;
   r := FindNext(DirInfo);
 end;
 if Not Found then Writeln('NOT Found ' + archivo + ' in <' + StartDir + '>');
 r := FindFirst(StartDir + '\*.*', FaDirectory, DirInfo);
 while r = 0 do  begin
   if (DirInfo.Attr and FaDirectory = FaDirectory) and (DirInfo.Name <> '.') and (DirInfo.Name <> '..') then
     Directorio(StartDir+'\'+DirInfo.Name, Archivo);
   r := FindNext(DirInfo);
 end;
 SysUtils.FindClose(DirInfo);
end;

var i: integer;

begin
 WriteLn('NotHere 0.1 by Kwanbis - Developed in Borland Delphi.');
 if ParamCount < 2 then begin
   WriteLn('Syntaxis: nothere fullpath filename');
   Halt(1);
 end;
 Write('Parameters: ');
 for i := 0 to ParamCount do Write(ParamStr(i));
 WriteLn;
 WriteLn;
 Directorio(ExcludeTrailingPathDelimiter(ExpandFileName(ParamStr(1))), ParamStr(2));
 WriteLn('DONE. Press <ENTER> to finish.');
 ReadLn;
end.

mazy
hello ...

i made a small gui util for doing all that stuff i need. it supports drag'n'drop so you can drop folders to process with it and then drag results for example to foobar.

it's rather slow atm, not-threated and you can't stop it while in progress. you can specify multiple folders to process, multiple folder names to skip (w/ wildcards), multiple 'missing' files (w/ wildcards), multiple 'including' files (w/ wildcards) and filter (return all results / only top-level or bottom-level).

folder, to get onto results' list, among other things needs to have no matching file from 'missing' list and at least one from 'including' list. you can set 'including' list to blank and disable that feature. setting it to '*' would make it return only non-empty folders (for that, only files count, not subfolders).

link

user posted image
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.