# VGMdb Redbook Dummy File Creator

> **Status:** Active
> **Category:** Data Extraction
> **Language:** Python 3
> **Script file:** `createdummyfiles (careful).py`

## Purpose

Creates a mirrored directory tree of zero-byte placeholder files from a Usenet/NZB share JSON export. Useful for previewing or cataloguing a share's folder and file structure without downloading the actual content.

## Requirements

### Dependencies

Uses the Python standard library only — no installation required.

```bash
# No pip install needed
# Requires: os, json, re (stdlib)
```

## Input

| Item | Description | Example |
|------|-------------|---------|
| `usershare_export.json` | Directory listing JSON export from a Usenet or NZB share tool | Place in the same directory as the script |

### JSON Structure

The file is expected to be an array of two-element tuples: `[folder_path_string, files_list]`. Each entry in `files_list` is itself a list where the second element (`[1]`) is the filename.

```json
[
  ["Music\\2021\\Artist - Album", [["nzb", "track01.flac", ...], ...]],
  ...
]
```

The script handles JSON with trailing commas (common in some exporters) by stripping them before parsing.

## Output

| Item | Description |
|------|-------------|
| Mirrored directory tree | All folders from the JSON are created under the hardcoded base path |
| Zero-byte placeholder files | One empty file created per entry in each folder's file list |

## Usage

Place `usershare_export.json` in the same directory as the script, then run:

```bash
python "createdummyfiles (careful).py"
```

Folders and files that already exist are silently skipped (`exist_ok=True`). Any OS errors during folder or file creation are printed to the console and skipped rather than halting the script.

## Examples

```bash
# Input JSON entry:
# ["Music\\2020\\[CPCA-10105] Artist - Title", [["x", "01 - Track.flac"], ["x", "02 - Track.flac"]]]

# Result on disk (under base path):
# C:\test\redbook\dummy\Music\2020\[CPCA-10105] Artist - Title\01 - Track.flac  (0 bytes)
# C:\test\redbook\dummy\Music\2020\[CPCA-10105] Artist - Title\02 - Track.flac  (0 bytes)
```

## Name Sanitisation

Folder and file names have the following characters replaced with underscores to ensure Windows filesystem compatibility:

```
< > : " / \ | ? * ／
```

Names are also truncated to a maximum of 150 characters.

## Notes

- **Hardcoded base path:** The output root directory is hardcoded as `C:\test\redbook\dummy`. This must be edited in the script before running if you want output elsewhere — change the `base_path` variable on line 10.
- The script name intentionally includes "(careful)" as a reminder that it can create a very large number of folders and files depending on the size of the JSON export.
- Folder paths in the JSON use Windows backslash separators (`\\`). The script splits on `\\` to reconstruct the path using `os.path.join`, which should work cross-platform, though the hardcoded base path is Windows-specific.
- The script only reads the second element of each file entry as the filename (index `[1]`). Other elements (e.g. file type or size) are ignored.

## Related Scripts

- [VGMdb Nicotine Shares](vgmdb-nicotineshares.md) — also parses a share JSON export, extracting catalogue numbers from folder paths instead of creating dummy files
