# vgmdb-urlcleaner

> **Status:** Active
> **Category:** URL Management
> **Language:** PowerShell
> **Script files:** `URL CLEAN FULL CLEAN.ps1`, `URL CLEAN STAGE 2 ONLY.ps1`

## Purpose

Batch-cleans Windows `.url` internet shortcut files across multiple pre-configured folders, stripping each file down to a minimal two-line format and upgrading `http://` URLs to `https://`. Two variants cover different folder scopes.

## Requirements

### Dependencies

PowerShell 5.1 or later (Windows built-in). No additional modules required.

## Input

| Item | Description | Example |
|------|-------------|---------|
| `.url` files | Windows internet shortcut files to be cleaned | `Album info.url` |
| Folder list | Hardcoded list of folder paths inside each script | `C:\stage 2 game` |

## Output

| Item | Description |
|------|-------------|
| Cleaned `.url` files | Rewritten in place to contain only `[InternetShortcut]` and `URL=https://...` |
| Console log | Colour-coded per-file status output |

### Output `.url` format

After cleaning, every `.url` file contains exactly:

```ini
[InternetShortcut]
URL=https://vgmdb.net/album/12345
```

Any extra lines, embedded icons, browser metadata, or additional INI sections are removed.

## Scripts

### `URL CLEAN FULL CLEAN.ps1` — Full multi-folder cleaner

Scans a hardcoded list of folders and for each `.url` file:

1. Strips any lines beyond `[InternetShortcut]` and `URL=...`
2. Upgrades `http://` to `https://`

**Hardcoded source folders:**

```
C:\stage 2 game
S:\[FINAL QUALITY CONTROL]
C:\[VGMPP Final Quality Edit]\Game QC
P:\VGMPP2025
P:\OLDSYNCSTUFF
S:\[READY to SEND]
S:\[STAGE2]
```

**Console output colours:**

| Colour | Meaning |
|--------|---------|
| Green | File was cleaned (extra data removed and/or URL upgraded) |
| Gray | File was already in minimal format — no changes needed |
| Red | No `URL=` line found — file was skipped |

---

### `URL CLEAN STAGE 2 ONLY.ps1` — Stage 2 variant

Identical logic but scans only `V:\[STAGE2]`. Does **not** upgrade `http://` to `https://` — it only strips extra metadata. Use `URL CLEAN FULL CLEAN.ps1` when you also need the http-to-https upgrade.

## Usage

```powershell
# Full clean across all configured folders
& ".\URL CLEAN FULL CLEAN.ps1"

# Clean Stage 2 folder only
& ".\URL CLEAN STAGE 2 ONLY.ps1"
```

## Examples

```powershell
# Run the full cleaner
& ".\URL CLEAN FULL CLEAN.ps1"

# Console output example:
# Scanning folder: C:\stage 2 game
# ✔ Cleaned & URL updated: C:\stage 2 game\Artist - Album\Album info.url
# ✔ Cleaned (no URL change): C:\stage 2 game\Artist - Album2\Album info.url
# ✓ No cleanup needed: C:\stage 2 game\Artist - Album3\Album info.url
# ⚠ Skipped (no URL= found): C:\stage 2 game\Misc\broken.url
```

## Notes

- **All folder paths are hardcoded** — edit the `$folders` array at the top of each script before running in a different environment.
- Both scripts are **destructive**: files are rewritten in place with no backup. Run a dry-run check manually or use [url-cleaner-v4](url-cleaner-v4.md) (which has cleaner rollback potential) if you want to preview changes first.
- `URL CLEAN STAGE 2 ONLY.ps1` does **not** perform the `http://` → `https://` upgrade — it only strips extra INI lines. `URL CLEAN FULL CLEAN.ps1` does both.
- Files with no `URL=` line (empty or malformed `.url` files) are skipped — they appear in red in the console but are not modified.
- The scripts use `-LiteralPath` to handle folder names containing special characters like `[` and `]` without glob expansion.

## Related Scripts

- [url-cleaner-v4](url-cleaner-v4.md) — Python equivalent with a live progress dashboard and summary statistics; handles any directory passed as an argument rather than using hardcoded paths
- [vgmdb-compareurl](vgmdb-compareurl.md) — Includes an http-to-https upgrader (`http to https.ps1`) with similar functionality
- [vgmdb-url2list](vgmdb-url2list.md) — Extract URLs from `.url` files into a CSV after cleaning
