How to search for two folders at the same time?
Moderators: Hacker, petermad, Stefan2, white
-
- Junior Member
- Posts: 22
- Joined: 2011-11-29, 14:40 UTC
How to search for two folders at the same time?
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?
From the TC help (press F1 in TC's search):Use quotes when searching for names with spaces.
Regards
Dalai
. In your specific case you'd typeMultiple search masks can be entered, separated by spaces
Code: Select all
DTAR_08E86330_4835_4B5C_9E5A_61F37AE1A077_DTAR obj
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
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64
Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
-
- Junior Member
- Posts: 22
- Joined: 2011-11-29, 14:40 UTC
I tried before asking, but doesn't work with and without [x] Everything option.Dalai wrote:typeUse quotes when searching for names with spaces.Code: Select all
DTAR_08E86330_4835_4B5C_9E5A_61F37AE1A077_DTAR obj
Mmh, seems that every directory name must be changed into a pattern, like so:
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
Code: Select all
DTAR_08E86330_4835_4B5C_9E5A_61F37AE1A077_DTAR* obj*
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
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64
Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
-
- Junior Member
- Posts: 22
- Joined: 2011-11-29, 14:40 UTC
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?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*
PowerShell: Find folder with two named sub folders
I only found a way by utilizing PowerShell:
I have this folders:
I open a PoSh console in "X:\temp\SearchTEST\" and type:
My result is:
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
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}
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.
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.
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.
-
- Junior Member
- Posts: 22
- Joined: 2011-11-29, 14:40 UTC
@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.
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.
No, i need to delete only obj folder in the same DTAR_*_DTAR folder and keep all others untouched.MVV wrote:Are there any obj folders w/o DTAR_08E86330_4835_4B5C_9E5A_61F37AE1A077_DTAR folder that should be removed?
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...