Created
January 11, 2018 02:39
-
-
Save JasonKleban/264c041ceebd2ec70051233981170e0f to your computer and use it in GitHub Desktop.
Powershell find in files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-ChildItem -r C:\Repos\... | | |
Select-String -Pattern '^\s*import\s+((?:[^\s{]+)|(?:\*\sas\s[^\s]+))\s+from\s+[''"](\.[^''"]*)[''"];?\s*$' -AllMatches | | |
Foreach-Object { "import $($_.Matches.Groups[1].Value) from '$([System.IO.Path]::GetFullPath([System.IO.Path]::Combine([System.IO.Path]::GetDirectoryName($_.Path), $_.Matches.Groups[2].Value.replace("/", "\"))))'" } | |
Get-Unique |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment