Skip to content

Instantly share code, notes, and snippets.

@JasonKleban
Created January 11, 2018 02:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JasonKleban/264c041ceebd2ec70051233981170e0f to your computer and use it in GitHub Desktop.
Save JasonKleban/264c041ceebd2ec70051233981170e0f to your computer and use it in GitHub Desktop.
Powershell find in files
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