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

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -