Find directories without specific files.

English support forum

Moderators: white, Hacker, petermad, Stefan2

MeTAlMollY
Junior Member
Junior Member
Posts: 18
Joined: 2003-03-13, 14:55 UTC
Location: Netherlands

Find directories without specific files.

Post by *MeTAlMollY »

Hello all,

I'm looking for a way to find all directories which don't contain specific files.

Currently I have some 200 folders (including some sub folders). Most of these (sub)folders contain a file named folder.jpg, some of them don't. Now I looking for a way to list the folders not holding this file.
I assume this is possible with the Search Files feature, but I don't know how? Can somebody give me a solution?

Thanks,
Mark
User avatar
Peter
Power Member
Power Member
Posts: 2064
Joined: 2003-11-13, 13:40 UTC
Location: Schweiz

Post by *Peter »

Try this (untested; attention: I use the German version, so maybe my description does not use exactly the English strings):

search (Alt-F7)
Register "Plugins":
- search in Plugins: YES
- 1. Line: Plugin: tc / full (file) name / !contains / "myfile.txt"
- 2. Line: Plugin: tc / directory / = / YES

Peter
TC 10.xx / #266191
Win 10 x64
MeTAlMollY
Junior Member
Junior Member
Posts: 18
Joined: 2003-03-13, 14:55 UTC
Location: Netherlands

Post by *MeTAlMollY »

Hi Peter,

Thanks for the suggestion, but it doesn't seem to work. Using these settings it still returns all directories (also the ones holding the file).

Mark
User avatar
Peter
Power Member
Power Member
Posts: 2064
Joined: 2003-11-13, 13:40 UTC
Location: Schweiz

Post by *Peter »

Strange ...

can you post a screenshot of your settings in the search-dialogue?

Peter
TC 10.xx / #266191
Win 10 x64
User avatar
Hacker
Moderator
Moderator
Posts: 13052
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

Peter,
If there is a file like "c:\SearchedDir\Notmyfile.txt" its dir will be a successful match.

Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
Peter
Power Member
Power Member
Posts: 2064
Joined: 2003-11-13, 13:40 UTC
Location: Schweiz

Post by *Peter »

Peter wrote:...- 1. Line: Plugin: tc / full (file) name / !contains / "myfile.txt"...
Hacker,

you are right. I think the first line should be (untested)

Code: Select all

1. Line: Plugin: tc / full (file) name / != / "myfile.txt"
TC 10.xx / #266191
Win 10 x64
User avatar
Hacker
Moderator
Moderator
Posts: 13052
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

Peter,
I think "c:\SearchedDir\BlaBla.txt" would be a successful match for the dir c:\SearchedDir, too - it is a dir and it does not contain myfile.txt in the result, even if the next searched file might be "c:\SearchedDir\myfile.txt".

Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
MeTAlMollY
Junior Member
Junior Member
Posts: 18
Joined: 2003-03-13, 14:55 UTC
Location: Netherlands

Post by *MeTAlMollY »

Hi all,

@Peter: Using the != also doesn't give the expected results. It actually gives the same results as using the !contains operator. I have something like this. The idea is that search gives me the dirs not folder the file.
But I don't want to see the dirs on the first level as they never hold this file. I think this is part of the problem sorry if this was not clear before.

Code: Select all

Music Share Folder
	Artist Name\Album Name
	Artist Name\Album Name\Folder.jpg
	Artist Name\Album Name\CD_1
	Artist Name\Album Name\CD_2\Folder.jpg
	Artist Name\Album Name
When I use you options and

Code: Select all

1. Plugin: tc / full (file) name / !contains / "myfile.txt" 
2. Line: Plugin: tc / directory / = / YES
and
1. Line: Plugin: tc / full (file) name / != / "myfile.txt"
2. Line: Plugin: tc / directory / = / YES
See screendumps
http://img207.imageshack.us/img207/3261/tcsearchop1.jpg
http://img11.imageshack.us/img11/864/tcsearchop2.jpg

Regards, Mark
User avatar
HolgerK
Power Member
Power Member
Posts: 5406
Joined: 2006-01-26, 22:15 UTC
Location: Europe, Aachen

Post by *HolgerK »

As Hacker pointed out:
TC.Fullname is not the content of a directory but the complete path string of the file or directory.

If you want to search for folders that do contain or do not contain a specific file you should try another approach.
E.g.:
- Install the Script Content Plugin
- Save the following script to the plugin dir:

<NoFolderJpg.vbs>

Code: Select all

'--- NoFolderJpg.vbs,  HolgerK
'-----       Search for folder which does not contain a folder.jpg file
'--- Script for Script Content Plugin 0.2
'--- Lev Freidin (c) 2005-2008
'--- http://www.totalcmd.net/plugring/script_wdx.html
'--- http://wincmd.ru/plugring/script_wdx.html

Dim fso, folder, fileCollection
Searchfilename = LCase("folder.jpg")
content = "Not present"
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FolderExists(filename) Then
	Set folder = fso.GetFolder(filename)
	Set fileCollection = folder.Files
	If fileCollection.Count = 0 Then
		content = "Empty Folder(no files!)"
	Else
		For Each file in fileCollection
			If LCase(file.Name) = Searchfilename Then
				content = "Present"
				Exit For
			End If
		Next
	End If
else
	content = "Not a folder"
End If
Set fileCollection = Nothing
set folder = Nothing
set fso = Nothing
- modify the <script.ini> file to:

Code: Select all

[Script]
Section=NoFolderJpg

[NoFolderJpg]
Script=NoFolderJpg.vbs
LongName=1
ParseDirs=1
- Search for(plugins tabs):

[x] Search in plugins:
[script] [result] [=] [Not present]

HTH
Holger
MeTAlMollY
Junior Member
Junior Member
Posts: 18
Joined: 2003-03-13, 14:55 UTC
Location: Netherlands

Post by *MeTAlMollY »

HolgerK, thanks this works fine!

I already knew the script plugin, but I thought TC supports such specific searches out of the box.
For me it doesn't look like a very uncommon request "Display all folders (starting at a certain subdirectory level) not holding a specific file"?

Regards,
Mark
User avatar
HolgerK
Power Member
Power Member
Posts: 5406
Joined: 2006-01-26, 22:15 UTC
Location: Europe, Aachen

Post by *HolgerK »

Hmmh, "specific search" and "common task" does not really fit together.

It's the way TC can be expanded to support specific tasks: content plugins.

BTW: another way is to modify the script in this way:
<FolderList.vbs>

Code: Select all

'--- FolderList.vbs,  HolgerK
'-----       Return the list of files contained in a folder as '|' separated string
'--- Script for Script Content Plugin 0.2
'--- Lev Freidin (c) 2005-2008
'--- http://www.totalcmd.net/plugring/script_wdx.html
'--- http://wincmd.ru/plugring/script_wdx.html

Dim fso, folder, fileCollection
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FolderExists(filename) Then
	Set folder = fso.GetFolder(filename)
	Set fileCollection = folder.Files
	content = "|"
	content1 = fileCollection.Count
	For Each file in fileCollection
		content = content + LCase(file.Name) + "|"
	Next
else
	content = ""
	content1 = 0
End If
Set fileCollection = Nothing
set folder = Nothing
set fso = Nothing
<scipt.ini>

Code: Select all

[Script]
Section=FolderList

[FolderList]
Script=FolderList.vbs
LongName=1
ParseDirs=1 
and define a search like this:

[x] Search in plugins:
[script] [result1] [!=] [0]
[script] [result] [!contains] [|folder.jpg|]

A little bit more flexible, because the searched filename is variable, but this may be limited to the maximum string length supported by TC (don't know the exact value here).

Regards
Holger
VadiMGP
Power Member
Power Member
Posts: 672
Joined: 2003-04-05, 12:11 UTC
Location: Israel

Post by *VadiMGP »

2MeTAlMollY
You can also try FileMask plugin.
User avatar
Peter
Power Member
Power Member
Posts: 2064
Joined: 2003-11-13, 13:40 UTC
Location: Schweiz

Post by *Peter »

HolgerK wrote:...
- Save the following script to the plugin dir:

<NoFolderJpg.vbs>
...
Does it really work? I changed "content" to "result", but I get no resulkt..

Peter
TC 10.xx / #266191
Win 10 x64
User avatar
fenix_productions
Power Member
Power Member
Posts: 1979
Joined: 2005-08-07, 13:23 UTC
Location: Poland
Contact:

Post by *fenix_productions »

2MeTAlMollY
Maybe this will help:
http://www.ghisler.ch/board/viewtopic.php?t=19993
"When we created the poke, we thought it would be cool to have a feature without any specific purpose." Facebook...

#128099
User avatar
HolgerK
Power Member
Power Member
Posts: 5406
Joined: 2006-01-26, 22:15 UTC
Location: Europe, Aachen

Post by *HolgerK »

Peter wrote:
HolgerK wrote:...
- Save the following script to the plugin dir:

<NoFolderJpg.vbs>
...
Does it really work? I changed "content" to "result", but I get no resulkt..
Hmmh yes it works here. Just did a test again with the code from my posting.
Saved Search from wincmd.ini:

Code: Select all

NoFolderJpg_SearchFor=
NoFolderJpg_SearchIn=
NoFolderJpg_SearchText=
NoFolderJpg_SearchFlags=0|000002000020|||||||||0000|
NoFolderJpg_plugin="script.Result = "Not Present""
- Did you adapt the scrip.ini file in the plugin dir?
- Please do not change the variable name "content"{N} in the vbs-file!
These variables are used by the plugin to create the content of the "script.result{N}" fields.

About the second script <FolderList.vbs>:
The limitation of the string lenght used in TC7.04a seem to be a maximum of ~1024 characters.
So this will fail in case of directories with more then 20 files, where each file has an average file length about 50 characters.

Regards
Holger
Post Reply