Skip to main content

📁 Remove Folder via URL-Encoded Path

This PowerShell script is designed to remove a folder when its path is provided in a URL-encoded format. It can be especially useful in automation pipelines or tools where folder paths are passed as encoded parameters.

Features

  • Accepts a folder path as a parameter ($FolderPath)

  • Automatically unescapes URL-encoded characters (e.g., %20 becomes a space)

  • Removes the specified folder and all its contents, if it exists

📜 Script
param (
    [string]$FolderPath = ""
)

# Unescape the URL-encoded path
$unescapedFolderPath = [Uri]::UnescapeDataString($FolderPath)

if (Test-Path -Path $unescapedFolderPath) {
    Remove-Item -Path $unescapedFolderPath -Recurse -Force
}

This script permanently deletes the folder and its contents. Ensure the path provided is correct and safe to delete.

Ideal for use in cleanup tasks, temp directory deletion, or post-deployment teardown processes.