Remove character from filename in powershell
2 answers
Use single quotes to remove or replace characters in the filename, '
and backslash for "special" characters \
, so the regular expression parser takes it literally.
The following removes the $
(dollar sign) sign from all filenames in your current directory:
Get-Item * | ForEach-Object { rename-item $_ ($_.Name -replace '\$', '') }
same as above, using a shorter alias for each command:
gi * | % { rni $_ ($_.Name -replace '\$', '') }
Next, the standard character " Z
" is removed from all filenames in your current directory:
gi * | % { rni $_ ($_.Name -replace 'Z', '') }
+2
source to share