Skip to content

Commit a98232f

Browse files
author
Doug
committed
Initial Commit
1 parent 1fa95cf commit a98232f

File tree

3 files changed

+109
-0
lines changed

3 files changed

+109
-0
lines changed

GCOrganizer.au3

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
2+
#AutoIt3Wrapper_UseX64=y
3+
#AutoIt3Wrapper_Change2CUI=y
4+
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
5+
#include <File.au3>
6+
#include <String.au3>
7+
#include <WinAPI.au3>
8+
9+
Local $nBytes = 6 ; IDs are only 6 characters
10+
Global $path = @ScriptDir & "\games\" ; Match layout of USB Loader GX
11+
Global $version = "1.0.0"
12+
13+
ConsoleWrite(@CRLF & "=== Gamecube Organizer v" & $version & " ===" & @CRLF)
14+
ConsoleWrite(@CRLF & "Gathering file list..." & @CRLF)
15+
16+
$files = _FileListToArray($path, "*.iso", 1, False) ; Only ISO's. Multiple filers would require _FileListToArrayRec()
17+
18+
If Not IsArray($files) Then
19+
ConsoleWrite("Oops! Something went wrong." & @CRLF & "No files could be found in: " & $path & @CRLF & "Exiting Program." & @CRLF)
20+
Exit
21+
EndIf
22+
If $files[0] <= 0 Then
23+
ConsoleWrite("Oops! The directory is empty." & @CRLF & "No files could be found in: " & $path & @CRLF & "Exiting Program. " & @CRLF)
24+
Exit
25+
EndIf
26+
27+
ConsoleWrite(UBound($files)-1 & " files found!" & @CRLF)
28+
ConsoleWrite("Starting loop..." & @CRLF)
29+
Sleep(1500)
30+
31+
For $i = 1 To $files[0] ; Loop every ISO found
32+
If StringInStr($files[$i], "[") > 0 And StringInStr($files[$i], "]") > 0 Then ; Filename has the ID in title, dont need to HEX reader
33+
$dirName = StringReplace($files[$i], ".iso", "")
34+
DirCreate($path & $dirName)
35+
FileMove($path & $files[$i], $path & $dirName & "\game.iso")
36+
checkSuccess($i, $files[0], $dirName)
37+
Else ; Need to read ID from first 6 HEX
38+
$tBuffer = DllStructCreate("byte[6]") ; Create our buffer
39+
$file = _WinAPI_CreateFile($path & $files[$i], 2, 2) ; Open the file as read only
40+
_WinAPI_SetFilePointer($file, 0, 0) ; Start at the beggining
41+
_WinAPI_ReadFile($file, $tBuffer, 6, $nBytes) ; Read the next 6 bytes
42+
_WinAPI_CloseHandle($file)
43+
$sText = BinaryToString(DllStructGetData($tBuffer, 1)) ; Convert the binary to a readable string
44+
; Need to validate the ID: 6 Characters, No Spaces, AlphaNumeric, No empty 6th character
45+
If StringLen($sText) = 6 and StringInStr($sText, " ") = 0 and StringIsAlNum($sText) and StringIsXDigit(StringRight($sText, 1)) Then
46+
$dirName = StringReplace($files[$i], ".iso", "") & " [" & $sText & "]"
47+
DirCreate($path & $dirName)
48+
FileMove($path & $files[$i], $path & $dirName & "\game.iso")
49+
checkSuccess($i, $files[0], $dirName)
50+
Else
51+
ConsoleWrite($i & "/" & $files[0] & ": Failed To Read (" & $files[$i] & ")" & @CRLF)
52+
EndIf
53+
$tBuffer = Null ; Clear buffer to avoid memory leak
54+
EndIf
55+
Next
56+
57+
Func checkSuccess($currentRow, $maxRows, $directoryName)
58+
If FileExists($path & $directoryName & "\game.iso") Then
59+
ConsoleWrite($currentRow & "/" & $maxRows & ": Success! (" & $directoryName & ")" & @CRLF)
60+
Else
61+
ConsoleWrite($currentRow & "/" & $maxRows & ": Failed To Copy (" & $directoryName & ")" & @CRLF)
62+
EndIf
63+
EndFunc ;==>checkSuccess

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 hotdog
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Gamecube ISO Organizer
2+
3+
I made this after I realized that a specific directory layout was required for USB Loader GX to recognize my Gamecube back ups.
4+
It will cycle through all available game ISO's, read their unique ID, create the directory and rename/move the ISO.
5+
6+
## Getting Started
7+
8+
Create a 'games' folder in the same location of this binary. Drop all of your .iso files into 'games' and then run the CUI binary.
9+
10+
### Prerequisites
11+
12+
I never tried this on ISO's that have been shrunk, but as long as it keeps the first 6 bytes of data in the file, they will work.
13+
14+
### Installing
15+
16+
Download the latest release binary or compile using SciTE w/ AutoIT.
17+
18+
## Built With
19+
20+
* [SciTE](https://www.autoitscript.com/site/autoit-script-editor/downloads/) - Customised version of SciTE with lots of additional coding tools for AutoIt
21+
* [AutoIT 3.3.14.2](https://www.autoitscript.com/) - Runtime & Build tools
22+
23+
## License
24+
25+
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details

0 commit comments

Comments
 (0)