powershell - Check file extension (htm) if not rename to htm -
i'm trying construct powershell script check file extensions in folder , if not rename extension .htm
. putting proving more difficult.
what have is:
new-item -itemtype directory -force -path c:\gp_services set-location c:\gp_services $root = get-childitem foreach($file) { $txtfile =".htm" $files = gci | where-object {$_.extension -eq ".htm"} else (rename-item -newname) { $_.name + '.htm' }
there no else
where-object
. need check if extension not equal .htm
, rename file matching criterion:
get-childitem | where-object { $_.extension -ne '.htm' } | rename-item -newname { $_.basename + '.htm' }
Comments
Post a Comment