according to topic:

Batch script to remove # from a file name (only in a specific directory)

is there a quick way to extend powershell command (from @Peter Hahndorf answer) to make it work on subfolders to? Or how it could be done? (using powershell).

Thanks in advance!


Batch solution, change the path to fit your environment.

@Echo off
for /f "delims=" %%A in ('Dir /B/S "X:\path\to\start\*#*" 2^>Nul') do (
    set "fn=%%~nxA"
    Call ren "%%A" "%%fn:#=%%"

A PowerShell one liner doesn't need a ForEach as Rename-Item accepts piped input:

Get-ChildItem '*#*' -File -Recurse | Rename-Item -NewName {$_.Name -Replace '#'}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.