Find directories without specific files.
Moderators: Hacker, petermad, Stefan2, white
-
- Junior Member
- Posts: 18
- Joined: 2003-03-13, 14:55 UTC
- Location: Netherlands
Find directories without specific files.
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
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
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
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
Win 10 x64
-
- Junior Member
- Posts: 18
- Joined: 2003-03-13, 14:55 UTC
- Location: Netherlands
Hacker,Peter wrote:...- 1. Line: Plugin: tc / full (file) name / !contains / "myfile.txt"...
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
Win 10 x64
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
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.
-
- Junior Member
- Posts: 18
- Joined: 2003-03-13, 14:55 UTC
- Location: Netherlands
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.
When I use you options and
See screendumps
http://img207.imageshack.us/img207/3261/tcsearchop1.jpg
http://img11.imageshack.us/img11/864/tcsearchop2.jpg
Regards, Mark
@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
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
http://img207.imageshack.us/img207/3261/tcsearchop1.jpg
http://img11.imageshack.us/img11/864/tcsearchop2.jpg
Regards, Mark
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>
- modify the <script.ini> file to:
- Search for(plugins tabs):
[x] Search in plugins:
[script] [result] [=] [Not present]
HTH
Holger
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
Code: Select all
[Script]
Section=NoFolderJpg
[NoFolderJpg]
Script=NoFolderJpg.vbs
LongName=1
ParseDirs=1
[x] Search in plugins:
[script] [result] [=] [Not present]
HTH
Holger
-
- Junior Member
- Posts: 18
- Joined: 2003-03-13, 14:55 UTC
- Location: Netherlands
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>
<scipt.ini>
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
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
Code: Select all
[Script]
Section=FolderList
[FolderList]
Script=FolderList.vbs
LongName=1
ParseDirs=1
[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
- fenix_productions
- Power Member
- Posts: 1979
- Joined: 2005-08-07, 13:23 UTC
- Location: Poland
- Contact:
Hmmh yes it works here. Just did a test again with the code from my posting.Peter wrote:Does it really work? I changed "content" to "result", but I get no resulkt..HolgerK wrote:...
- Save the following script to the plugin dir:
<NoFolderJpg.vbs>
...
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""
- 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