How to search for two folders at the same time?

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
george60120
Junior Member
Junior Member
Posts: 22
Joined: 2011-11-29, 14:40 UTC

How to search for two folders at the same time?

Post by *george60120 »

Due to bug in VS 2015, my HDD is full of two folders always come together DTAR_08E86330_4835_4B5C_9E5A_61F37AE1A077_DTAR and obj, what should i type in "Search for:" to find them?
User avatar
Dalai
Power Member
Power Member
Posts: 9387
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai »

From the TC help (press F1 in TC's search):
Multiple search masks can be entered, separated by spaces
. In your specific case you'd type

Code: Select all

DTAR_08E86330_4835_4B5C_9E5A_61F37AE1A077_DTAR obj
Use quotes when searching for names with spaces.

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
george60120
Junior Member
Junior Member
Posts: 22
Joined: 2011-11-29, 14:40 UTC

Post by *george60120 »

Dalai wrote:type

Code: Select all

DTAR_08E86330_4835_4B5C_9E5A_61F37AE1A077_DTAR obj
Use quotes when searching for names with spaces.
I tried before asking, but doesn't work with and without [x] Everything option.
User avatar
Dalai
Power Member
Power Member
Posts: 9387
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai »

Mmh, seems that every directory name must be changed into a pattern, like so:

Code: Select all

DTAR_08E86330_4835_4B5C_9E5A_61F37AE1A077_DTAR* obj*
But that feels odd, and I was sure that it's possible to search without asterisks... A dot instead of an asterisk works, too.

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
george60120
Junior Member
Junior Member
Posts: 22
Joined: 2011-11-29, 14:40 UTC

Post by *george60120 »

Dalai wrote:Mmh, seems that every directory name must be changed into a pattern, like so:

Code: Select all

DTAR_08E86330_4835_4B5C_9E5A_61F37AE1A077_DTAR* obj*
That worked, but what i really want is listing obj ONLY if the same folder contain "DTAR_08E86330_4835_4B5C_9E5A_61F37AE1A077_DTAR", (because all VS solution folders contains obj folder) is this possible?
User avatar
Stefan2
Power Member
Power Member
Posts: 4157
Joined: 2007-09-13, 22:20 UTC
Location: Europa

PowerShell: Find folder with two named sub folders

Post by *Stefan2 »

I only found a way by utilizing PowerShell:

I have this folders:

Code: Select all

X:\temp\SearchTEST\Folder1\DTAR_08E8
X:\temp\SearchTEST\Folder1\obj

X:\temp\SearchTEST\Folder2\DEF
X:\temp\SearchTEST\Folder2\DTAR_08E8
X:\temp\SearchTEST\Folder2\DEF\obj

X:\temp\SearchTEST\Folder3\DEF
X:\temp\SearchTEST\Folder3\DTAR_08E8

X:\temp\SearchTEST\Folder3\DEF\DTAR_08E8
X:\temp\SearchTEST\Folder3\DEF\obj

X:\temp\SearchTEST\Folder4\obj

X:\temp\SearchTEST\Folder5\DTAR_08E8

X:\temp\SearchTEST\Folder6\DTAR_08E8
X:\temp\SearchTEST\Folder6\obj



I open a PoSh console in "X:\temp\SearchTEST\" and type:

Code: Select all

PS X:\temp\SearchTEST>ls -re| %{IF($_.Name -like "DTAR_08E8*"){ls(Split-Path $_.FullName) -Fil obj}}|%{$_.FullName}
My result is:

Code: Select all

X:\temp\SearchTEST\Folder1\obj
X:\temp\SearchTEST\Folder3\DEF\obj
X:\temp\SearchTEST\Folder6\obj



You can play around with comparison operators '-like' and '-eq' if need.
If you know the name exactly, use ' -eq "ExcatName" ', else use ' -like "*regex*" '.


We also can add a trailing " |Out-File zzzFolderList.txt " to write the output to a file.





The exact PoSh commands (I used abbreviation above) are:

Get-ChildItem -Recurse|
ForEach-Object{IF($_.Name -like "DTAR_08E8*"){Get-ChildItem (Split-Path $_.FullName)|
Where-Object{$_.Name -eq "obj"}|ForEach-Object{$_.FullName}}}
| Out-File zzzFolderList.txt


EDIT:
I just remind myself on "-Filter", that makes the command line even shorter (by removing the Where-Object) and increase the speed (by filtering the processed data at first place):

Get-ChildItem -Recurse|
ForEach-Object{IF($_.Name -like "DTAR_08E8*"){Get-ChildItem (Split-Path -parent $_.FullName) -Filter obj}}|
ForEach-Object{$_.FullName}


ls -rec| %{IF($_.Name -like "DTAR_08E8*"){ls(Split-Path $_.FullName) -Fil obj}}|%{$_.FullName}

So I adjusted my command above at top of this post.

- - -


The command do perform this steps:
- DIR current folder recursive
- IF folder name is like (-like) "DTAR_08E8*" THEN
---- DIR that very folder ....AND:
-------- IF folder name (-eq) "obj" is found
-------------- output the full path



 
Last edited by Stefan2 on 2017-05-26, 12:07 UTC, edited 1 time in total.
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Can't you just search for DTAR_08E86330_4835_4B5C_9E5A_61F37AE1A077_DTAR folders in such case? Are there any obj folders w/o DTAR_08E86330_4835_4B5C_9E5A_61F37AE1A077_DTAR folder that should be removed?

When you have found all DTAR_08E86330_4835_4B5C_9E5A_61F37AE1A077_DTAR folders, you can use simple script that will remove adjacent obj folders also.
george60120
Junior Member
Junior Member
Posts: 22
Joined: 2011-11-29, 14:40 UTC

Post by *george60120 »

@Stefan2

Thanks, i didn't used Power Shell before, beside i can do my own script but i was need to know if there is a simple TC method.
MVV wrote:Are there any obj folders w/o DTAR_08E86330_4835_4B5C_9E5A_61F37AE1A077_DTAR folder that should be removed?
No, i need to delete only obj folder in the same DTAR_*_DTAR folder and keep all others untouched.
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

There is no simple method in such specific case. However I think there is a way to do it within TC - you can search for obj folders and use script content plugin for checking if DTAR_08E86330_4835_4B5C_9E5A_61F37AE1A077_DTAR folders exist in the same parent folders...
Post Reply