-----------------------------------------------------------------------------------------------
[Name]          Replay Manager (Lite edition)
[Purpose]       Organizing Gensou Ningyou Enbu replay files (rename / sort into folders)
[Version]       3.0
[Website]       https://https://xy1.ebb.jp/03
[Author]        くしち (Kushichi) (https://x.com/xyichi)
[Released]      2026.7.19
[Requirements]  Windows 10 / 11
-----------------------------------------------------------------------------------------------

** About **
"幻想人形演舞(Gensou Ningyou Enbu)
  /Touhou Puppet Dance Performance" (TPDP)
  (http://www.fo-lens.net/enbu_ap/)
and 
"幻想人形演舞-ユメノカケラ-(Gensou Ningyou Enbu: Yumeno Kakera)
  /Touhou Puppet Dance Performance: Shard of Dreams" (TPDP SoD)
  (http://www.fo-lens.net/enbu_ap/).
This document assumes you are already familiar with the games and where their
replay files are stored, so those topics are not covered here.
This document assumes you are already familiar with the games and where their
replay files are stored, so those topics are not covered here.

This tool comes in two editions.
Lite edition: smaller, but requires 64-bit Windows and the ".NET 8 Desktop Runtime"
(https://dotnet.microsoft.com/en-us/download/dotnet/8.0) (about 240 KB).
Full edition: no runtime needed; The file size is larger (about 65 MB).

!!!!! We strongly recommend backing up the target files before use. !!!!!
The author accepts no responsibility for any damage caused by using this tool.


** Install / Uninstall **
Extract the archive to any folder and run it from there.
The tool does not touch the registry and does not create any files.
To uninstall, simply delete the extracted folder.

** Tested Environment **
- Windows 11
- Gensou Ningyou Enbu ver 1.31 / 1.34
- Gensou Ningyou Enbu -Yume no Kakera- ver 1.103
- Gensou Ningyou Enbu -Yume no Kakera- Extended (unofficial expansion patch)
(Replay files from other versions are also recognized and classified.)


** How to Use **
Run the bundled "ReplayManager.exe".

1. Drag & drop .rep files, or a folder containing .rep files, onto the window
   (you can also use the browse buttons).
2. The processing target (game & version, own player name) is detected
   automatically from the loaded files. The most common one is preselected,
   so you can usually leave it as is.
3. Choose the "Folder sorting" and "Rename" settings.
   Everything defaults to "No" — nothing happens to your files until you
   explicitly choose an action.
4. Check the before/after list at the bottom. Clicking a row toggles its
   checkbox; unchecked files are not processed.
5. Press [Apply] to execute (after a confirmation).

Example:
Say your player name is "Me" and you fought someone named "You",
and the resulting replay file is "240120_000000.rep" (a 7-turn battle).
Applying with Rename = Yes changes the filename to
"240120_000000_Me_You_7.rep".
If Folder sorting = Yes is also applied, the file moves into a folder
named "You".


** Specifications **
[ Processing target ]
The target is defined by the pair "game (Enbu / Yume no Kakera) + version"
and "own player". Only files whose player 1 (= the side that saved the
replay) matches the selected own player are processed.

Files outside the target (different version, different game, or a different
player 1) are never renamed. They appear greyed out as "Out of scope" in the
list. Selecting "Out-of-scope files: Sort into other folders" moves them,
without renaming, into these dedicated folders:
- player 1 is not your own player          ->  "%OtherPlayers"
- other versions of the same game          ->  "%OtherVer"
- the other game (any version)             ->  "%TPDP" or "%SoD"
- files that cannot be read as replays     ->  "%Unknown"

[ Folder sorting ]
With Folder sorting = Yes, target files move into a folder named after the
opponent (player 2).

[ Rename ]
The filename format is
"Date_Time_OwnName_OpponentName_(extra)_Turns.rep".
Individual fields can be excluded with the checkboxes.

The date/time at the head of the original filename is carried over with top
priority. If the original filename has none, it is reconstructed from the
replay's internal data, but this can differ from the actual battle start time
by 1-2 minutes.

Three policies are available for already-renamed files:
- Leave unchanged ... files whose names do not match the format below
                      (e.g. manually renamed ones) are left untouched.
- Carry over      ... renames while keeping the non-format part in the
                      "(extra)" position.
- Refresh         ... renames from scratch, discarding the non-format part.

The old RepFileRenamer format "YYMMDD_HHMMSS：Me-You.rep" is recognized
automatically, so player names are never appended twice. If you had manually
edited such a name, the edited part can be carried over as "(extra)".

If a player name contains characters that cannot be used in filenames, they
are converted to full-width characters. The following characters apply
(including "_" used as the separator and "%" used as the prefix of the
dedicated folders):
/:*?"<>|\_%

If the destination name collides with an existing file, a sequence number
such as "_001" is appended.

[ Same-name png files ]
If a .png file with the same name as a .rep exists, it automatically follows
the .rep when moved or renamed. It is shown in blue directly under its .rep in
the list. png files cannot be processed independently. A png without a
same-name .rep is not processed.

[ Miscellaneous ]
You can only load a single folder, or .rep files from the same folder.
When a folder is dropped, only the files directly inside it are targeted;
files in subfolders are not.
Files whose extension is not .rep are not loaded.

Although extremely unlikely, if an unrelated file happens to have the .rep
extension and an internal structure resembling an Enbu replay, it could be
processed. In that case, please restore the filename manually.


** Change History **
[ver 3.0: 2026.07.17]
Renamed to "Replay Manager" and fully redesigned (successor to RepFileRenamer)
Added folder sorting (per-opponent + classification of out-of-scope files)
Switched to selecting a processing target (game x version x own player)
Customizable filename format; handling of already-renamed / old-format files
(leave unchanged / carry over / refresh)
Same-name png files follow their .rep; preview list with selective apply;
Japanese / English support

[ver 2.0: 2025.08.08]
Relaunched as the “RepFileRenamer” application
UI improvements such as a log view and a progress gauge
Support for large files; unified per-file processing time
Windows-forbidden characters in player names are now converted to full-width
characters instead of being removed
Unified handling of both Enbu and Yume no Kakera replays

[ver 1.0: 2024.01.24]
File paths are now loaded via drag & drop
Both players' names are now read and applied automatically

[ver 0: 2023.12.17]
Created as a PowerShell script with manually entered target folders and
opponent names


** Credit **
The executable/window icon uses publicly released image material by FocasLens
(http://www.fo-lens.net/enbu_ap/download.html).

"幻想人形演舞 (Gensou Ningyou Enbu / Touhou Puppet Dance Performance)"
and
"幻想人形演舞-ユメノカケラ- (Gensou Ningyou Enbu Yume no Kakera
 / Touhou Puppet Dance Performance: Shard of Dreams)"
are the works of　the doujin circle FocasLens (http://www.fo-lens.net/)
 / 幻想人形劇団(Gensou Ningyou Gekidan)(https://x.com/gn_gekidan),
and are derivative works of Touhou Project.

"Touhou Puppet Dance Performance" and "Touhou Puppet Dance Performance: Shard of Dreams" are
 an unofficial English title.

"Touhou Puppet Dance Performance: Shard of Dreams -Extended-"
(http://gensoushinki.com/index.php?lang=ja) is an unofficial expansion patch
created by Barudo (https://twitter.com/Nukekip) and their team.

This tool is an unofficial creation by くしち (Kushichi) (individual).
Please do NOT contact FocasLens, Gensou Ningyou Gekidan, or Barudo's team
about this tool — it would only cause them trouble.
