Forum Discussion

manny213's avatar
manny213
Brass Contributor
Nov 08, 2024
Solved

Remove characters from a file name

Hi everyone I have a bunch of CSV files in a folder that need to be cleaned up.  Both the file name and file contents have unneeded apostrophes.  I need the apostrophes removed from the file name on...
  • LainRobertson's avatar
    Nov 08, 2024

    Hi manny213 ,

     

    A simple one-liner can handle this.

     

    Get-ChildItem -Path "D:\Data\Temp\Forum" | ForEach-Object { Rename-Item -Path $_.FullName -NewName "$($_.Name.Replace("'", ''))"; }

     

    Example

     

    Cheers,
    Lain

Resources