Warning: Undefined array key "rcommentid" in /var/www/busted.dk/public_html/blog/wp-content/plugins/wp-recaptcha/recaptcha.php on line 348

Warning: Undefined array key "rchash" in /var/www/busted.dk/public_html/blog/wp-content/plugins/wp-recaptcha/recaptcha.php on line 349
Rename/remove characters from files and folders. - Peter Busted

Rename/remove characters from files and folders.

This is a powershell script that removes or renames special characters from files or folder.

Very useful if you are going to upload a lot of files to SharePoint or OneDrive and you files contains illegal characters.

$folder = ‘c:\mytest’
Get-ChildItem $folder -Recurse | ? {$_ -match ‘%|#|_’} | sort psiscontainer, {$_.fullname.length * 1} | % {ren $_.FullName $($_.name -replace ‘%|#’ -replace ‘_’, ‘ ‘)}