Convert FrontPage Templates to Dreamweaver
I have about 21000 html files created years ago using FrontPage. They all use the same template (filetype dwt), but were in a folder called "Common" not "Templates" like Dreamweaver requires.
I made a change within the old FP template to reflect the layout of my current web site and tested it on a few files. Since the old template isn't in the Templates folder, I need to figure out a way to have Dreamweaver update all those 21000 html files. I can't just move the old template into the Templates folder because all the 21000 files have references to the template in them. I can't do a find and replace of the template name and change the directory in the 21000 files because the path is in an uneditable region in each file.
I wrote a PowerShell script and ran it as Administrator.
$filenames = @(get-childitem -Path "C:\Users\denny\OneDrive\dennyptravel\Web Sites\httpdocs\*" | % { $_.FullName })
foreach ($file in $filenames)
{
$replacementStr = 'Templates/main2.dwt'
(Get-Content $file) |
Foreach-object { $_ -replace 'common/main2.dwt' , $replacementStr } |
Set-Content $file
Write-Host Processed $file
}I ran it on a subset of my 21000 files that I copied into a test directory on my local c: drive. It worked fine. Then I went to run it on my live files (which happen to be on a OneDrive directory). I received this error on every file.
+ CategoryInfo : PermissionDenied: (C:\Users\denny\...\httpdocs\2007w:String) [Get-Content], Unauthorized
AccessException
+ FullyQualifiedErrorId : GetContentReaderUnauthorizedAccessError,Microsoft.PowerShell.Commands.GetContentCommandI then ran the following command in PowerShell in admin mode.
Set-ExecutionPolicy RemoteSignedWhen I reran the find/replace code, I got the same access errors.
Any ideas on eliminating the access errors or perhaps have another Find/Replace solution that would work against 21000 files? Thank you.
