How to search folders that contain certain files

English support forum

Moderators: Hacker, petermad, Stefan2, white

Post Reply
shawn
Junior Member
Junior Member
Posts: 36
Joined: 2007-04-05, 17:30 UTC

How to search folders that contain certain files

Post by *shawn »

TC has great search functions, but I have trouble to search for this.

For example, A folder has a bunch of sub folders like B1, B2, B3, ... etc. Some of these folders have file C, and some don't.

I want to search all B folders with file C. In other words, I want B folders as the search result not C.

Is this possible?
shawn
Junior Member
Junior Member
Posts: 36
Joined: 2007-04-05, 17:30 UTC

Post by *shawn »

So, it's impossible in TC?
:(
Kyles
Junior Member
Junior Member
Posts: 22
Joined: 2014-04-01, 01:58 UTC

Post by *Kyles »

1. Alt+F7
2. Search for: fill in file C
3. Switch to Plugins tab
4. Enable [v]Search in plugins
5. Plugin: select tc
6. Property: select path
7. OP: select contains
8. Value: fill in B
9. Press [Start search]
shawn
Junior Member
Junior Member
Posts: 36
Joined: 2007-04-05, 17:30 UTC

Post by *shawn »

Sorry, but it's not what I want.
It still gives me file C as the search result, but I want to find the parent folder B, which contains C.
Ralph
Member
Member
Posts: 100
Joined: 2004-08-21, 14:58 UTC
Location: USA

Post by *Ralph »

This topic looks similar to http://www.ghisler.ch/board/viewtopic.php?t=39949; maybe the topics could be combined.

It is possible to get the "B" folders as the search result in TC, since addons are part of TC's capabilities. One way to do this is to use the DiskDir Extended addon. There are multiple steps, but they are easy.

0. First, install the DiskDir Extended plugin (http://www.ghisler.com/plugins.htm). Use of the extension .lsx is assumed here. (I use the .lst extension for the DiskDir plugin.)

1. Search for the files of interest (Alt+F7).
. Click on Feed to listbox, to create a virtual panel.
In the other panel, choose a target directory to hold the .lsx file that will be created.

2. Select all of the files in the virtual panel.
Open the Pack dialog (Alt+F5).
. Make sure that the name of the .lsx file to be created does not match an existing file in the target panel.
. Make sure that Also pack path names and Recursively pack subdirectories are checked.
. Using the Packer drop-down arrow, select the lsx "packer."
. OK.

3. Double-click on the .lsx file to cause TC to display the contents as a virtual directory structure.
Open the Search dialog (Alt+F7).
. Under the General tab, clear the Search for box.
. Under the Advanced tab, Attributes, select Directory.
. Start search and Feed to listbox.

If you want to see the directories in a virtual directory structure:
4. Select the files in the virtual panel that you just created.
Open the Pack dialog (Alt+F5) and use the lsx "packer" as above. The .lsx file to be created must not exist already.
Double-click on the second .lsx file to see the directories of interest. The .lsx file is just a text file, so it can be edited or used for other purposes.
shawn
Junior Member
Junior Member
Posts: 36
Joined: 2007-04-05, 17:30 UTC

Post by *shawn »

Thank you very much, Ralph!

It's a very interesting solution. I've never used this pack files function before.

After my second search, I got the B folders, but the "Feed to listbox" button is disabled. I guess this is the limitation when searching within a pack.lst file.

Besides, my goal is to move the B folders with C file to somewhere else, and leave B folders without C where they are. The pack solution can "Copy" the search result folders, but not move them. :(
shawn
Junior Member
Junior Member
Posts: 36
Joined: 2007-04-05, 17:30 UTC

Post by *shawn »

The good thing is, after open the lst file, I can get a list of the B folders I want. I can select all and ^+2 to copy the folder names, then write a batch script to move them.

However, it's not an easy job and kind of defeat the purpose. I thought TC could do better than that.

:D
Ralph
Member
Member
Posts: 100
Joined: 2004-08-21, 14:58 UTC
Location: USA

Post by *Ralph »

Now I better understand your goal; you probably can skip my sections 3 and 4.

Here is a method to select the relevant actual (not virtual) directories, but the method is not elegant. Maybe someone knows a more convenient way.
. In the virtual directory created in my section 2 (or 4) above, select all directories (which will be those containing the files of interest).
. In the menu bar, click on Mark and Save Selection To File.
. Edit the selection file and remove the parent directory path d:\...\A\ for all entries. (This could be done via search and replace or via column block deletion in a program editor. Depending on your editor, you might need to change from Unicode to ASCII, for example while doing Save As from NotePad.)
. View the actual contents of your directory A.
. In the menu bar, click on Mark and Load Selection From File.

In this case, since you can use the method above to select the actual directories of interest, you probably will not need a bat file. If you want to create a bat file, you can use the MakeBat plugin.

DiskDir Extended is accessed via the Pack dialog because the Pack dialog will send a list of the selected files or directories to DiskDir Extended, and not because DiskDir Extended has anything to do with compression.

If the Feed to listbox button is disabled, I wonder if you are using the most recent version of TC. If you accidentally had used DiskDir instead of DiskDir Extended, I think you would not have been able to do the search for directories in my section 3.
Last edited by Ralph on 2014-04-08, 04:27 UTC, edited 1 time in total.
shawn
Junior Member
Junior Member
Posts: 36
Joined: 2007-04-05, 17:30 UTC

Post by *shawn »

OMG, that's the trick I am looking for!!!
Much appreciated!

PS, I am using version 7.56a.
Ralph
Member
Member
Posts: 100
Joined: 2004-08-21, 14:58 UTC
Location: USA

Post by *Ralph »

You might want to get the latest version of TC.
TC now can do Feed to listbox with results of searches within compressed files. That probably is why my version of TC could do the second Feed to listbox.
sky66
Member
Member
Posts: 176
Joined: 2014-02-22, 08:44 UTC

Post by *sky66 »

Another methods:

FileInDir 1.1
Plugin can be used to search for directories which contain specified file with specified text content.
http://www.totalcmd.net/plugring/fileindir.html

But it only support TC 32bit, and need to set the fileindir.ini before use search function in TC 32bit.

fileindir.ini example:

Code: Select all

[Search01]
IgnoreCase=1
SearchFile=file C
SearchContent=
shawn
Junior Member
Junior Member
Posts: 36
Joined: 2007-04-05, 17:30 UTC

Post by *shawn »

The more choices, the better.
However, FileInDir doesn't work for me.

I installed the plugin.
Open fileindir.ini and set SearchFile=*.mp4
Alt+F7 open search window
Leave blank in "Search for" and set Attributes to be "Directory"
Check off "Search in plugins"
Choose FileInDir plugin and set value = YES

It took a long time to search and didn't find anything. :(
Tried a couple of times and TC crashed.

It seems to me this plugin is not very stable yet
shawn
Junior Member
Junior Member
Posts: 36
Joined: 2007-04-05, 17:30 UTC

Post by *shawn »

Wait...

This plugin is for searching string in text file content.
I only need to search for file name.
shawn
Junior Member
Junior Member
Posts: 36
Joined: 2007-04-05, 17:30 UTC

Post by *shawn »

Now I see why you setup the ini file this way. You need to set SearchContent as blank!

Works great and it's even easier than Ralph's method! LOL
shawn
Junior Member
Junior Member
Posts: 36
Joined: 2007-04-05, 17:30 UTC

Post by *shawn »

This plugin is truly amazing!

You can even define a color schema to show a different color for the directories with the file you are interested!
Post Reply