Windows 10 How to recursively remove all PRG and P00 file extensions? E.g. in batch

MIRKOSOFT

Active Member
Joined
Sep 26, 2019
Messages
60
Hello!

I need to recursively to remove all extensions PRG and P00 on single partition.
I know that recursively can work XCOPY, but renaming is other task.
How to create batch to remove all these extensions of files and folders (if exist) recursively?

Thank you for each help, suggestion or reply and comments.
Miro
 


Great!
Only last Q - how to execute PowerShell script by command without opening PS console?

Thank you very much.
Miro
 


You need to make sure your execution policy will allow powershell scripts Set-ExecutionPolicy -Scope MachinePolicy -ExecutionPolicy RemoteSigned then you should be able to just run a script by right clicking it and say "Run with Powershell"
 


Policy I know that needs to allow.
I mean not execution by right click from menu.
Really command which can be used as submenu in context menu directly starting script, like BAT or CMD has batches - similar way.
Anything like
\CLASSES_ROOT\*\SHELL\Remove Extensions\command\(Default)...
...execute.bat "%1"
and so on...

Miro
 


Ok, tested, works.
How to embed PowerShell commands into BAT or CMD?
This is last Q.
Miro
 


You don't need to. Just call powershell.exe -command " & { <command> }"
 


Solution
Ok, finally - how to create PowerShell batch or embed PS batch (lines with PS code) into BAT or CMD?

Thank you for both answers.
Miro
 


Ok, how to embed whole script - this code:

Code:
$FilePath = $args[0]

$Filename = Split-Path -Path $FilePath -Leaf
$Content = Get-Content -Path "$FilePath" | Out-String
$MeasuredData = Measure-Object -InputObject $Content -Line -Word -Character

$FormattedOutput = "Extension $($FileName): Words: $($MeasuredData.Words) Lines: $($MeasuredData.Lines) Chars: $($MeasuredData.Characters)"

[System.Windows.Forms.MessageBox]::Show($FormattedOutput)
 


Back
Top