PoshCode Archive  Artifact Content

Artifact 0d4d8e861607c6664f996dc543c34e53a4426686997f5a0ee3e4d9d4eb39a1fe:

  • File Remove-Special-Char.ps1 — part of check-in [5490060956] at 2018-06-10 14:07:30 on branch trunk — This will recursively remove non-alphanumeric\decimal (via regex) characters from all folder and filenames. The decimals are left in tact for file extensions. (user: mjohnson size: 629)

# encoding: ascii
# api: powershell
# title: Remove Special Char
# description: This will recursively remove non-alphanumeric\decimal (via regex) characters from all folder and filenames. The decimals are left in tact for file extensions.
# version: 0.1
# author: mjohnson
# license: CC0
# x-poshcode-id: 6074
# x-archived: 2016-05-17T13:25:37
# x-published: 2016-10-30T09:31:00
#
# To replace the characters with another, modify the empty ‘ ‘) } section with your wanted word/char.
# Please use -whatif for testing.
#
gci 'c:\test\' -Recurse | % { Rename-Item $_.FullName $($_.Name -replace
	'[^\w\.]','') }