Created
March 3, 2019 18:48
-
-
Save stahler/78a27565ffaa9573a8b07beffc9b34e2 to your computer and use it in GitHub Desktop.
This file contains 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
# create some test files | |
1..9 | foreach -Begin { | |
Set-Location C:\TEMP | |
} -Process { | |
$str = "<html>NewFile$PSItem</html>" | |
Add-Content -Value $str -Path "./OldFile$PSItem.html" | |
} | |
# change the name of the test files | |
$files = Get-ChildItem O*.html | |
foreach ($file in $files) { | |
$text = Get-Content -Path $file.name | |
if ($text -match "<html>(?<name>.*)<\/html>") { | |
$newFile = $Matches.name | |
Rename-Item -Path $file.Name -NewName "$newFile.html" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment