Rom Cover Matching Script + 2D to Spine Convertor

Discussion in 'Wii - Emulation and Homebrew' started by syntax53, Aug 6, 2017.

  1. syntax53
    OP

    syntax53 Member

    Newcomer
    24
    15
    Jul 11, 2017
    United States
    So I recently embarked on getting Wiiflow mastermod setup. This led me to getting matching covers for all of my roms. I couldn't find a great tool to do this. I tried "fuzzy match" and "Cover-2-Rom" and a couple others. None gave me the versatility and precision I was looking for. So, like I usually do, I spend many hours writing my own scripts. So I'm sharing two scripts that I've completed.

    Download: https://www.dropbox.com/s/xdu3xf8q4s43z8z/rom_cover_matcher.7z?dl=1

    Note: You may need to add the "-executionpolicy bypass" switch before the "-f" (e.g. "powershell -executionpolicy bypass -f script_file.ps1") if your machine has restricted powershell policies turned on.

    _2DtoSpine.ps1
    The easier one to explain is a powershell script called, "_2DtoSpine.ps1". This script will scan an entire folder of covers and convert any "2D" images (any images smaller than the spine cover, really) to spine images. What I do is first determine the image sizes of each image in the folder. If it's not within a margin of error to the destination spine size, it will create a front cover of the spine format. It will then copy that to the back cover and insert a spine in the middle. So for example:
    convert.png combine2.png
    This makes 2d covers look great in wiiflow. Requires ImageMagick (free). Like I mentioned earlier though, all I'm looking for is images smaller than spine images. If you have 3D images or cart images in there, they probably won't look good converted to spines :P. Also, I didn't create a spine and add support for genesis because all of the genesis covers I found were already in spine format. Usage:
    Code:
    # GB:  powershell -f _2DtoSpine.ps1 -format "gb" -covers "f:\WiiFlow\boxcovers\vbagx\*.gb.png" -output "C:\Users\syntax\Desktop\covers"
    # GBC: powershell -f _2DtoSpine.ps1 -format "gbc" -covers "f:\WiiFlow\boxcovers\vbagx\*.gbc.png" -output "C:\Users\syntax\Desktop\covers"
    # GBA: powershell -f _2DtoSpine.ps1 -format "gba" -covers "f:\WiiFlow\boxcovers\vbagx\*.gba.png" -output "C:\Users\syntax\Desktop\covers"
    # SNES: powershell -f _2DtoSpine.ps1 -format "snes" -covers "F:\WiiFlow\boxcovers\snes9xgx" -output "C:\Users\syntax\Desktop\covers"
    # NES: powershell -f _2DtoSpine.ps1 -format "nes" -covers "F:\WiiFlow\boxcovers\fceugx" -output "C:\Users\syntax\Desktop\covers"
    _match_covers.ps1
    The other powershell script is called, "_match_covers.ps1". This is a massive script that took me a good 12 hours to code. At heart of it, it scans your roms and up to 2 local folders for covers, including an option to try and download the spine from thecoverproject.net, and if it finds a match, download/copy it to a folder. With (wiiflow) or without (emulators) the extension included in the image filename. Also Requires ImageMagick (free) only if you enable the switched to try and download images.

    It will also present you with a list of potential matches for file names that were similar but not exact enough to match. It will also spit out an HTML file listing every cover that has no match with links to search thecoverproject.net and Google directly. You can then download matching covers and I even provide commands you can run to automatically convert and resize any manual covers you download in one paste of text (see the comments at the top of _match_covers.ps1).

    So for me, I had it scan my spine covers as a primary source. I would then see what was missing, make some tweaks, etc. I would then add in the download option to see what it could pull from thecoverproject.net. Then I would manually download any games that I wanted to make sure I had real spine covers for. Convert those and drop them in. Next I would add in my backup folder of 2D covers for scanning. Once I reached full match, I'd run 2DtoSpine to convert everything to spine covers.

    You also have to option to have it automatically delete any roms at the end if you just want full covers with whatever you have. It also cleans up rom / cover names with any extraneous/doubles spaces. It will automatically scan for matches to a couple common name issues with "The", for example, coming at the beginning or end of a title. I also noticed a lot of Disney titles where people would or wouldn't put "Disney" in the file name so I scan for alts of that as well. Most importantly I have options built in to ignore any tags in the matching. So anything "(USA)" "[!]" etc tags will automatically be ignored (if desired) when matching.

    Without further ado, Usage:
    Code:
    # Usage--
    #
    # -op options: all, clean, copy, check
    # all: do all
    # clean: remove double-spaces from file names (THIS WILL MODIFY FILE NAMES IN YOUR SOURCE PATHS)
    # copy: copy/download matched covers, but don't clean filenames
    # check: report matched and missing covers and possible alternate matches, will also download if specified
    #
    # -roms "path to roms" -- NOTE: you can also filter this by specifying like -roms "c:\roms\a*.*" to only do A's
    # -covers "main path to covers"
    # -backup "backup path to covers" (optional - only used if first choice isn't available AND if download not available)
    # -dest "path to place downloads / matches" (optional if doing a "check" or "clean" OP)
    #
    # -download "path to save downloads": attempt to download missing covers from thecoverproject.com
    # -type: thecoverproject.com game type filename prefix -- gb, gbc, gba, nes, snes, genesis
    #
    # -add_ext: add extension to cover name (WIIFLOW)
    # -ignore_tags: ignore all (USA)[!] etc tags at the end of file names when matching
    # -overwite: force re-copy / overwrite
    # -delete_missing_roms: delete roms where covers are not found
    # -dont_copy_downloads: dont copy downloads: do this if you want to verify the downloaded covers are correct.  manually copy them yourself afterwards.
    #
    # ==================================================================================================================================================
    #
    # ** Recommended to wait before adding the download switches until you know you're matching most of them with your local copies.
    # ** Missing covers saved to "_missing_covers.html".  open it to quickly search thecoverproject.com.
    #
    #    -What you should do is first run just a scan on your main source folder (specify only: -op "all" -roms "path" -covers "path" -dest "path")
    #
    #    -Make sure the results are pretty much as expected.  It will list some potential cover matches that have varying names.  You can manually rename
    #     your roms and/or covers to make them match.  If you did that, run the same command again so it picks those changes up.
    #
    #    -Next, add the -download and -type options.  Then you can open "_missing_covers.html" and manualy search and download any from the list
    #     of still missing covers if you want to make sure they get the cover format you want.
    #
    #    -Lastly, REMOVE the download option (we know it's not going to find anything now), and ADD the -backup option to pull in any remaining covers
    #
    #    -Optionally, if you don't care about the roms that are still missing covers, throw in a -delete_missing_roms at the end
    #
    # ** You can quickly convert all of your manually downloaded covers with this command utilizing imagemagick:
    #
    #    genesis/snes/nes spines:    for /f "tokens=*" %A in ('dir /b /a-d *.*') do convert "%A" -strip -resize 1090!x680! "%~nA.png"  (then delete all non-PNG's)
    #    gb/gbc/gba spines:        for /f "tokens=*" %A in ('dir /b /a-d *.*') do convert "%A" -strip -resize 1090!x458! "%~nA.png"  (then delete all non-PNG's)
    #
    #    snes 2D:            for /f "tokens=*" %A in ('dir /b /a-d *.*') do convert "%A" -strip -resize 316!x224! "%~nA.png"  (then delete all non-PNG's)
    #    nes 2D:            for /f "tokens=*" %A in ('dir /b /a-d *.*') do convert "%A" -strip -resize 160!x224! "%~nA.png"  (then delete all non-PNG's)
    #    gb/gbc/gba 2D:       for /f "tokens=*" %A in ('dir /b /a-d *.*') do convert "%A" -strip -resize 224!x224! "%~nA.png"  (then delete all non-PNG's)
    #    ( i couldn't find a standard size for genesis - make changes to the above as necessary )
    #
    # ==================================================================================================================================================
    #
    # Exmaples--
    #
    # Simple check for matching covers to roms:
    # powershell -f _match_covers.ps1 -op "check" -roms "f:\snes9xgx\roms" -covers "P:\Games\ROMs\_COVERS\SNES\SPINE\USA (559 + 124 Alts)"
    #
    # WiiFlow:
    # ---------------------
    # SNES: powershell -f _match_covers.ps1 -op "all" -roms "f:\snes9xgx\roms" -covers "P:\Games\ROMs\_COVERS\SNES\SPINE\USA (559 + 124 Alts)" -dest "F:\WiiFlow\boxcovers\snes9xgx" -add_ext -download "C:\Users\syntax\Desktop\covers" -type "snes" -backup "P:\Games\ROMs\_COVERS\SNES\2D"
    #
    # NES: powershell -f _match_covers.ps1 -op "all" -roms "F:\fceugx\roms" -covers "P:\Games\ROMs\_COVERS\NES\SPINE" -dest "F:\WiiFlow\boxcovers\fceugx" -add_ext -download "C:\Users\syntax\Desktop\covers" -type "nes" -backup "P:\Games\ROMs\_COVERS\NES\2D"
    #
    # GENESIS: powershell -f _match_covers.ps1 -op "all" -roms "F:\genplus\roms\MD" -covers "P:\Games\ROMs\_COVERS\SGEN\SPINE" -dest "F:\WiiFlow\boxcovers\genplusgx" -add_ext -ignore_tags -download "C:\Users\syntax\Desktop\covers" -type "genesis"
    #
    # GB: powershell -f _match_covers.ps1 -op "all" -roms "F:\vbagx\roms\gb" -covers "P:\Games\ROMs\_COVERS\GB\GB\SPINE" -dest "F:\WiiFlow\boxcovers\vbagx" -add_ext -ignore_tags -backup "P:\Games\ROMs\_COVERS\GB\GB\2D" -download "C:\Users\syntax\Desktop\covers" -type "gb"
    #
    # GBC: powershell -f _match_covers.ps1 -op "all" -roms "F:\vbagx\roms\gbc" -covers "P:\Games\ROMs\_COVERS\GB\GBC\SPINE" -dest "F:\WiiFlow\boxcovers\vbagx" -add_ext -ignore_tags -backup "P:\Games\ROMs\_COVERS\GB\GBC\2D" -download "C:\Users\syntax\Desktop\covers" -type "gbc"
    #
    # GBA: powershell -f _match_covers.ps1 -op "all" -roms "F:\vbagx\roms\gba" -covers "P:\Games\ROMs\_COVERS\GB\GBA\SPINE" -dest "F:\WiiFlow\boxcovers\vbagx" -add_ext -ignore_tags -backup "P:\Games\ROMs\_COVERS\GB\ALL\2D" -download "C:\Users\syntax\Desktop\covers" -type "gba" -dont_copy_downloads
    #
    # Regular Emulators:
    # ------------------
    #
    # SNES: powershell -f _match_covers.ps1 -op "all" -roms "f:\snes9xgx\roms" -covers "P:\Games\ROMs\_COVERS\SNES\2D" -dest "F:\snes9xgx\covers\2D"
    # NES: powershell -f _match_covers.ps1 -op "all" -roms "F:\fceugx\roms" -covers "P:\Games\ROMs\_COVERS\NES\2D" -dest "F:\fceugx\covers\2D"
    # GB: powershell -f _match_covers.ps1 -op "all" -roms "F:\vbagx\roms\gb" -covers "P:\Games\ROMs\_COVERS\GB\GB\2D" -backup "P:\Games\ROMs\_COVERS\GB\ALL\2D" -dest "F:\vbagx\covers\2D" -ignore_tags
    # GBC: powershell -f _match_covers.ps1 -op "all" -roms "F:\vbagx\roms\gbc" -covers "P:\Games\ROMs\_COVERS\GB\GBC\2D" -backup "P:\Games\ROMs\_COVERS\GB\ALL\2D" -dest "F:\vbagx\covers\2D" -ignore_tags
    # GBA: powershell -f _match_covers.ps1 -op "all" -roms "F:\vbagx\roms\gba" -covers "P:\Games\ROMs\_COVERS\GB\GBA\2D" -backup "P:\Games\ROMs\_COVERS\GB\ALL\2D" -dest "F:\vbagx\covers\2D" -ignore_tags
    # Genesis: powershell -f _match_covers.ps1 -op "all" -roms "F:\genplus\roms\MD" -covers "P:\Games\ROMs\_COVERS\SGEN\SNAPS" -backup "P:\Games\ROMs\_COVERS\SGEN\2D" -dest "F:\genplus\snaps\md" -ignore_tags
    #
    
     
    Last edited by syntax53, Aug 30, 2017
  2. JasonH

    JasonH Advanced Member

    Newcomer
    57
    12
    May 28, 2016
    United States
    Links are dead for both tools. Are there any better links?
     
  3. syntax53
    OP

    syntax53 Member

    Newcomer
    24
    15
    Jul 11, 2017
    United States
    Sorry about that. Not sure what happened. Fixed the download link.
     
    markehmus likes this.
  4. syntax53
    OP

    syntax53 Member

    Newcomer
    24
    15
    Jul 11, 2017
    United States
    updates to both scripts--

    -Changed ImageMagick support to v7. NO LONGER COMPATIBLE WITH V6.
    -Fixed some potential issues with special characters in path names
    -flipped GB/GBC/GBA spines (2d to spine) to make them look more natural in wiiflow