PDA

View Full Version : Modified script to allow roms to be located lettered subfolders



Toxicshadow
02-26-2011, 07:21 AM
Hi all,

Not sure if this is any use to anyone but I have modifed the HyperLaunch.ahk script to allow roms to be located in sub folders of individual letters as follows:

e.g

snes-->
----> 0-9
----> a
----> b
----> c

I prefer to store my roms this way becuase it is easier to find the rom you require. In the above example you just configure hyperspin to point to the snes folder and the script will automatically determine the sub folder based upon the first letter in the rom name.

Here is the modified section of the script (items in bold have been added):

if(systemName != "zinc")
{
If (romExtensions = "")
{
MsgBox,48,Error, Missing rom extension in %systemName%.ini ,6
Goto ExitScript
}
Loop, parse, romExtensions, `,
{
inputVar = %A_LoopField%
romVar = %RomName%

StringLeft, charToCheck, inputVar, 1

StringLeft, firstRomChar, romVar, 1

If(firstRomChar = "0" || firstRomChar = "1" || firstRomChar = "2" || firstRomChar = "3" || firstRomChar = "4" || firstRomChar = "5" || firstRomChar = "6" || firstRomChar = "7" || firstRomChar = "8" || firstRomChar = "9")
{
subfolderVar = 0-9
}else{
subfolderVar = %firstRomChar%
}

If(charToCheck = ".")
{
MsgBox,48,Error, Make sure your rom extensions do not contain a ".",6
Goto ExitScript
}
IfExist %RomPath%%RomName%.%A_LoopField%
{
romExtension = .%A_LoopField%
romFound = true
break
}else{
IfExist %RomPath%%RomName%\%RomName%.%A_LoopField%
{
RomPath = %RomPath%%RomName%\
romExtension = .%A_LoopField%
romFound = true
break
}else{
IfExist %RomPath%%subfolderVar%\%RomName%.%A_LoopField%
{
RomPath = %RomPath%%subfolderVar%\
romExtension = .%A_LoopField%
romFound = true
break
}else{
romFound = false
}
}
}
}
}
if (romFound = "false")
{
if(systemName != "daphne"){
MsgBox,48,Error,Cannot find Rom - %RomPath%%RomName% with any provided extension,6
Goto ExitScript
}else{
MsgBox,48,Error,Cannot find Daphne framefile - %RomPath%%RomName% with any provided extension,6
Goto ExitScript
}
}
return

irondragoon
02-26-2011, 07:37 AM
Nice work.

AutoHotKey supports regular expressions if you wanted to trim down your big If || conditional

http://www.autohotkey.com/docs/commands/RegExMatch.htm

Off the cuff, might need tweaking:
RegExMatch(firsRomChar, \d) != -1

Dazz
02-26-2011, 09:13 AM
This isn't a bad idea; if you aren't using a front end. However, why would you need to do this if you are using a front end? This makes auditing ROMs much more difficult.

Toxicshadow
02-26-2011, 11:24 AM
Tbh, it was something that i started doing many years ago. I found that windows would take a considerable amount of time to open a folder because it had over 1000 files in it.

Plus some emulators like zsnes would take forever to search through a large list of roms in order to find the one I wanted so this seemed like the most logical approach.

I guess I could put them all back into one folder nowadays but its just easier not to mess with it and thankfully it was fairly simple to modify the script to do what I needed.

Tempest
02-27-2011, 02:35 AM
Should you decide to change to a flat folder structure, you can use my Roms in (and out of) folders (http://emumovies.com/forums/index.php?/topic/2136-file-utility-roms-in-and-out-of-folders/page__p__5447__fromsearch__1#entry5447) to take your roms out of folders.

The program will NOT put them back in folders as you have them. It is intended to put roms that have multiple files types of the same name into a folder.

EG: Game1.iso, Game1.mdf, Game1.ext would all go into a folder named 'Game1'