Rename part of files

I would like to run a script that would ask user to drag in a path, then cd in to the folder. Then I need to rename . to a _ in the filenames.

Hey there,

This site is for helping with specific questions about code you are working on. We do not create scripts for users as we are all unpaid volunteers. If you have some code post it and use the ‘</>’ button to format the code and ask specific questions for what you are stuck on.

This is what I am trying to run

dir | rename-item -NewName {$_.name -replace "_","."}# Specify the path to the file
$filePath = "C:\path\to\file_with_underscore.tif"
$newFileName = (Get-Item $filePath).Name -replace ".0", "_0"
Rename-Item -Path $filePath -NewName $newFileName