Skip to content

Instantly share code, notes, and snippets.

@mcoms
Created December 14, 2012 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcoms/4288096 to your computer and use it in GitHub Desktop.
Save mcoms/4288096 to your computer and use it in GitHub Desktop.
Quick script to use WIT (http://wit.wiimm.de/) to move Wii (WBFS) backup files to a standard directory structure. Works with standard .wbfs files on a FAT/NTFS filesystem, for example.
require 'fileutils'
# Set the directory containing your backup files (they can be in sub-directories of this path)
f = Dir.glob './**/*.wbfs'
f.each do |n|
x = `wwt LIST \"#{n}\"`
if $?.success?
# WBFS containers can have multiple games in them. Here, we select just the first one for naming.
# Nearly always, you will have only backed up a single game per container anyway.
(id, name) = x.split("\n")[3].split(/\s{2,}/)
if id && name
# Filter out characters like ':' and '&' to make a filesystem-safe path
name.gsub!(/[^\w\s-]/, '')
name.squeeze!(' ')
# Set the final resting place (be careful if your OS' path separator isn't '/')
path = "./wbfs/#{name} [#{id}]/"
file = "#{id}.wbfs"
loc = "#{path}#{file}"
p "Moving game #{n} to #{loc}"
FileUtils.mkdir_p path
FileUtils.mv n, loc
end
end
end
# Example output:
Moving game ./Sin and Punishment 2 [R2VP01]/R2VP01.wbfs to ./wbfs/Sin and Punishment Successor of the Skies [R2VP01]/R2VP01.wbfs
Moving game ./Cooking Mama 2- World Kitchen wii pal wbfs/RWKPGT.wbfs to ./wbfs/Cooking Mama 2 World Kitchen [RWKPGT]/RWKPGT.wbfs
Moving game ./Need for Speed- Undercover [RX9P69]/RX9P69.wbfs to ./wbfs/Need for Speed Undercover [RX9P69]/RX9P69.wbfs
Moving game ./Wii Sports Resort [RZTP01]/RZTP01.wbfs to ./wbfs/Wii Sports Resort [RZTP01]/RZTP01.wbfs
Moving game ./Ratatouille [RLWP78]/RLWP78.wbfs to ./wbfs/Ratatouille [RLWP78]/RLWP78.wbfs
Moving game ./S2PPA4.wbfs to ./wbfs/Pro Evolution Soccer 2012 [S2PPA4]/S2PPA4.wbfs
Moving game ./Spider-Man- Shattered Dimensions [SPDP52]/SPDP52.wbfs to ./wbfs/Spider-Man Shattered Dimensions [SPDP52]/SPDP52.wbfs
# The following errors are fine - the script will incorrectly present directories to WIT, when they end in .wbfs
!! wwt: ERROR #29 [READ FILE FAILED] in AnalyzePartitions() @ src/wbfs-interface.c#433
!! Neither regular file nor char or block device: /legalbackups/Super.Mario.Allstars.wii.pal.wbfs
!! wwt: ERROR #17 [NO WBFS FOUND] in AnalyzePartitions() @ src/wbfs-interface.c#447
!! no WBFS partitions found -> abort
Moving game ./Super.Mario.Allstars.wii.pal.wbfs/SVMP01.wbfs to ./wbfs/Super Mario All-Stars 25th Anniversary Edition [SVMP01]//SVMP01.wbfs
Moving game ./RMKP01.wbfs to ./wbfs/Mario Sports Mix [RMKP01]/RMKP01.wbfs
Moving game ./Wii Party [SUPP01]/SUPP01.wbfs to ./wbfs/Wii Party [SUPP01]/SUPP01.wbfs
!! wwt: ERROR #29 [READ FILE FAILED] in AnalyzePartitions() @ src/wbfs-interface.c#433
!! Neither regular file nor char or block device: /legalbackups/Need.for.Speed.Hot.Pursuit.wii.pal.wbfs
!! wwt: ERROR #17 [NO WBFS FOUND] in AnalyzePartitions() @ src/wbfs-interface.c#447
!! no WBFS partitions found -> abort
Moving game ./Need.for.Speed.Hot.Pursuit.wii.pal.wbfs/SNHP69.wbfs to ./wbfs/Need for Speed Hot Pursuit [SNHP69]/SNHP69.wbfs
Moving game ./Zack and Wiki- Quest for Barbaros' Treasure [RTZP08]/RTZP08.wbfs to ./wbfs/Zack Wiki Quest For Barbaros Treasure [RTZP08]/RTZP08.wbfs
Moving game ./Pikmin 2 [R92P01]/R92P01.wbfs to ./wbfs/Pikmin 2 [R92P01]/R92P01.wbfs
Moving game ./Need for Speed- Carbon [RNSP69]/RNSP69.wbfs to ./wbfs/Need for Speed Carbon [RNSP69]/RNSP69.wbfs
Moving game ./Barbie Horse Adventures- Riding Camp [RRCP52]/RRCP52.wbfs to ./wbfs/Barbie Horse Adventures Riding Camp [RRCP52]/RRCP52.wbfs
Moving game ./SKZP52.wbfs to ./wbfs/DreamWorks Super Star Kartz [SKZP52]/SKZP52.wbfs
Moving game ./Wii Fit Plus [RFPP01]/RFPP01.wbfs to ./wbfs/Wii Fit Plus [RFPP01]/RFPP01.wbfs
Moving game ./RSVP8P.wbfs to ./wbfs/Sonic Unleashed [RSVP8P]/RSVP8P.wbfs
Moving game ./SMNP01.wbfs to ./wbfs/New Super Mario Bros Wii [SMNP01]/SMNP01.wbfs
Moving game ./Worms- A Space Oddity [RWMP78]/RWMP78.wbfs to ./wbfs/Worms A Space Oddity [RWMP78]/RWMP78.wbfs
Moving game ./Batman- The Brave and the Bold [S3BPWR]/S3BPWR.wbfs to ./wbfs/Batman The Brave and the Bold [S3BPWR]/S3BPWR.wbfs
Moving game ./Boom Blox- Bash Party [RYBP69]/RYBP69.wbfs to ./wbfs/Boom Blox Bash Party [RYBP69]/RYBP69.wbfs
Moving game ./EA Sports Active- More Workouts [SEAP69]/SEAP69.wbfs to ./wbfs/EA Sports Active More Workouts [SEAP69]/SEAP69.wbfs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment