# VGMDB URL Rename Combo — Python

> **Status:** Active
> **Category:** File Organization
> **Language:** Python 3
> **Script file:** `vgmdb-url-rename-combo-python.py`

## Purpose

Renames album folders and creates a VGMdb `.url` internet shortcut file inside each renamed folder in a single pass. Reads a pipe-separated input file (`folders.txt`) and processes every line — renaming the folder, then dropping a `.url` shortcut pointing to the album's VGMdb page. A PowerShell equivalent (`vgmdb-url-rename-combo-powershell.ps1`) is also included in the same directory.

## Requirements

Standard library only — no external packages required (`os`, `sys`, `argparse`, `datetime`, `pathlib`).

## Input

| Item | Description | Example |
|------|-------------|---------|
| `folders.txt` | Pipe-separated file listing rename pairs and URLs | See format below |
| Working directory | Script operates on folders relative to wherever it is run | `cd "D:\Music\FLAC"` |

### `folders.txt` format

Each line contains three fields separated by `|`:

```
old_folder_name|new_folder_name|https://vgmdb.net/album/1234
```

```
Artist - Album [OLD-001]|Artist - Album (2010)(OST) [GNCA-7163]|https://vgmdb.net/album/7163
Soundtrack Title [PCCG-00123]|Soundtrack Title (1997)(OST) [PCCG-00123]|https://vgmdb.net/album/456
```

Lines with fewer than three `|`-separated fields are skipped with a warning.

## Output

| Item | Description |
|------|-------------|
| Renamed folders | Each `old_folder_name` is renamed to `new_folder_name` in the working directory |
| `.url` shortcut files | `Album info.url` created inside each renamed folder, pointing to the given URL |
| Timestamped log | `combined_script_YYYY-MM-DD_HHMMSS_UTC±HHMM.log` written to the working directory |

### `.url` shortcut file format

Standard Windows internet shortcut format, readable by Explorer:

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

## Usage

```bash
# Default: reads folders.txt, creates "Album info.url" shortcuts
python vgmdb-url-rename-combo-python.py

# Custom input file
python vgmdb-url-rename-combo-python.py --input-file mylist.txt

# Custom shortcut filename
python vgmdb-url-rename-combo-python.py --url-filename "VGMdb.url"

# Both custom
python vgmdb-url-rename-combo-python.py --input-file mylist.txt --url-filename "VGMdb.url"
```

### PowerShell alternative

```powershell
.\vgmdb-url-rename-combo-powershell.ps1
```

The PowerShell version uses the same `folders.txt` input format.

## Examples

```bash
# Example 1 — Standard run from your music library root
cd "D:\Music\FLAC"
python vgmdb-url-rename-combo-python.py
# Reads folders.txt, renames folders, drops "Album info.url" in each

# Example 2 — Use a different input file and shortcut name
python vgmdb-url-rename-combo-python.py -i batch2.txt -u "vgmdb.url"

# Example 3 — Process a list while in a specific subdirectory
cd "D:\Music\FLAC\Doujin"
python "C:\scripts\vgmdb-url-rename-combo-python\vgmdb-url-rename-combo-python.py"
```

### Console output colours

| Colour | Meaning |
|--------|---------|
| Green (`Success`) | Folder renamed or shortcut created successfully |
| Red (`Error`) | Folder not found, target already exists, permission denied, or path too long |
| Yellow (`Warning`) | Invalid line format or missing URL |
| Cyan (`Info`) | General status messages |

## Notes

- If `old_folder_name` does not exist but `new_folder_name` does (i.e. the folder was already renamed), the script will still attempt to create the `.url` shortcut inside the existing `new_folder_name` folder.
- If neither folder exists, the script creates a new directory named `new_folder_name` and places the shortcut in it.
- The `input-file` is read with **UTF-8 encoding**. Save your `folders.txt` as UTF-8 to avoid errors with non-ASCII characters.
- The log file is created fresh on each run (not appended). Each run gets a unique timestamp in the filename.
- Summary statistics (rename count, URL shortcut count, error counts) are printed at the end of each run.

## Related Scripts

- [vgmdb-renamer-wildcard](vgmdb-renamer-wildcard.md) — renames folders by wildcard/pattern match without creating URL shortcuts
- [vgmdb-restructure-combined](vgmdb-restructure-combined.md) — reads the `.url` files created by this script to scrape album metadata
- [vgmdb-restructure](vgmdb-restructure.md) — two-step pipeline that also reads `.url` files
