Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to filter out filename that end in .table.sql or a two part extension?

I know how to do this with one extension in PowerShell, but since my files have a two part extension this is no longer working for me:

Get-ChildItem . -Recurse | Where-Object { $_.Extension -notin @("*.table.sql")}

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

The Extension property only contains the last . and whatever else trails after (.sql in your case).

You’ll want to test the whole Name instead, and you’ll want to use the -[not]like operator(s) for wildcard matching:

Get-ChildItem . -Recurse |Where-Object Name -notlike '*.table.sql'

If you want to include only *.sql files to begin with, use the -Filter parameter with Get-ChildItem:

Get-ChildItem . -Recurse -Filter '*.sql' |Where-Object Name -notlike '*.table.sql'
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading