1

I've been able to piece together this script to remove periods from the file names without affecting the extension. I've been struggling to make it run in the subdirectories without manually running it in each one.

This is the script I've been using:

dir | rename-item -newname {       
       [System.IO.Path]::GetFileNameWithoutExtension($_.name).Replace("."," ") + 
       [System.IO.Path]::GetExtension($_.name); }

Best,

Connor

3 Answers 3

2
Get-ChildItem -Recurse | Where-Object { $_.PSIsContainer -eq $false } | Rename-Item -NewName { $_.Basename.replace("."," ") + $_.Extension }

That's how I'd do it.

Sign up to request clarification or add additional context in comments.

Comments

1

try using something like dir -recurse

Comments

0

You can do recursive search(search subfolders) using the -Recurse switch for dir / Get-ChildItem.

I would also suggest using powershell properties instead of [System.IO.Path] functions:

$_.BaseName     #Filename without extension
$_.Extension    #File-extension

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.