Hacking Question Switch - auto xci renaming tool

simbin

Well-Known Member
OP
Member
Joined
Jul 28, 2015
Messages
588
Trophies
0
XP
1,387
Country
United States
wondering if it's possible to auto rename an entire folder of Switch xci files - based off their internal header info?

such a tool would be extremely useful for people backing up large collections
 

simbin

Well-Known Member
OP
Member
Joined
Jul 28, 2015
Messages
588
Trophies
0
XP
1,387
Country
United States

wurstpistole

GBAtemp MVP
Member
Joined
Nov 19, 2015
Messages
4,664
Trophies
1
XP
5,456
Country
United Kingdom
thanks I may end up using this, or just do it manually

bummer having to rely on scene releases, which are named funky

hopefully future tools will allow dumping our own carts, with better naming options
They just name it after the official game IDs , nothing funky about it.
 

thequickbrownfox

Well-Known Member
Newcomer
Joined
May 7, 2018
Messages
94
Trophies
0
Age
33
XP
660
Country
Poland
You need nothing else but BRU.

Using Bulk Rename Utility work on xci files in original folders, choose options "remove" to remove existing names and "append folder name", because with BBB releases folders are named clearly and correctly.
You will end up with xci files named exactly like folders, so instead of "bbb-h-aeqka.xci" you'll have "Overcooked.Special.Edition.NSW-BigBlueBox.xci".

Btw, BRU is an excellent tool, I can't imagine my life without it.
 
Last edited by thequickbrownfox,

snoofly

Well-Known Member
Member
Joined
Aug 18, 2015
Messages
1,012
Trophies
0
Age
54
XP
2,133
Country
United Kingdom
You need nothing else but BRU.

Using Bulk Rename Utility work on xci files in original folders, choose options "remove" to remove existing names and "append folder name", because with BBB releases folders are named clearly and correctly.
You will end up with xci files named exactly like folders, so instead of "bbb-h-aeqka.xci" you'll have "Overcooked.Special.Edition.NSW-BigBlueBox.xci".

Btw, BRU is an excellent tool, I can't imagine my life without it.
You're damn right about BRU - it's a godsend to collectors.
 

WolfThatGoesMoo

Active Member
Newcomer
Joined
Jun 1, 2018
Messages
43
Trophies
0
Age
39
XP
183
Country
United States
Hi, I've been a lurker for some time but I want to contribute to the scene if I can. I'm interested in making a program that does this, but I need a little help because I'm really a novice when it comes to this sort of thing.

I have already made a program that renames xci files in bulk by using another tool previously posted here.

Here's how my program does it:
It creates an array list of the file names from a given directory, and loops it into the tool "XCI Explorer.exe" in order to extract the name found within the Game info's group.
It then checks to see if the found name matches the file name. If it does...skip, else; it renames it appropriately. (Example: "bbb-h-adeba.xci" is renamed to "Just Dance 2018").
This works well but is very clunky and the form of automation I use requires the user to stop interacting with the machine until the script has finished processing. (Essentially an ugly macro).

Alternative method I attempted to use is to read the XML dump from nswdb and rename it that way, but I don't really care for this route. It relies on a third party to constantly update a database, or for me to build a scrapper for a
site that may be taken down often and well scraping can be rude. It's too easy for it to be outdated, and ideally, I want the name sourced locally without internet being required.

What I need help with:
Obtaining the information XCI Explorer displays....or if I could get a modified version of it with command parameters to have it just spit out the extracted file name, that would be very helpful.

I know..with that the work is basically done for me, but I'm not claiming nor attempting to make that part of the tool; especially when it's already made. Just trying to help out by making a re-naming tool.

Any help would be appreciated!

TLDR: Need help extracting header info to get game file name. I'm newb.
XCI Reader uses nswdb dump to get name, BRU method uses folder name, and my method uses XCI Explorer and slow af clunky automation macro to get game name. These all have problems!
 
Last edited by WolfThatGoesMoo,
  • Like
Reactions: simbin

c80

Banned!
Banned
Joined
Jun 1, 2018
Messages
270
Trophies
0
Age
44
XP
194
Country
Germany
Need help extracting header info to get game file name
Why do you want to get the info from the file? There is a website with the information: nswdb . com You can download the data as an xml file: nswdb . com/xml.php Isn't this all you need?
 

WolfThatGoesMoo

Active Member
Newcomer
Joined
Jun 1, 2018
Messages
43
Trophies
0
Age
39
XP
183
Country
United States
Why do you want to get the info from the file? There is a website with the information: nswdb . com You can download the data as an xml file: nswdb . com/xml.php Isn't this all you need?

There's 4 reasons why I want to grab the game title from the .xci file itself:

1st being that I am already using that method to get the xml file from nswdb, and the problem is that checking the crc32 of each file (especially the larger sized files) takes forever, and in thus renaming an entire directory of games can take up to 15 minutes in my testing and I don't have very many games (I only grabbed backups I have physical copies of because I want digital versions.)

2nd, the xml file can be outdated, taken down, relocated, etc making it require maintenance on my end which I'm not too interested in.

3rd, when dumping my own cartridge, my crc32 values are different from the node <imgcrc> supplied, and in thus, unless you're only using bbb's releases, this renaming method wouldn't work for you. That's just not ideal.

4th, I really don't feel this tool should force users to connect to the internet, especially when the information is locally source already, directly in the given directory.

--

Additional information:
I threw the xci's into HdX and see where headers were stripped and where they are trimmed, but I really don't know how to navigate through it to find the title. Can anyone point me to a guide of interpreting it? I've tried searching for the title
as a string converted to hex, and looking for the string as text and just haven't had any luck.
 
Last edited by WolfThatGoesMoo,
  • Like
Reactions: simbin

c80

Banned!
Banned
Joined
Jun 1, 2018
Messages
270
Trophies
0
Age
44
XP
194
Country
Germany
Obtaining the information XCI Explorer displays
have a look at private void LoadGameInfos() in MainForm.cs of XCI Explorer. It reads the meta data from the XCI file:
Code:
                using (FileStream fileStream = File.OpenRead(this.TB_File.Text))
                {
                    using (FileStream fileStream1 = File.OpenWrite("meta"))
                    {
                        BinaryReader binaryReader = new BinaryReader(fileStream);
                        BinaryWriter binaryWriter = new BinaryWriter(fileStream1);
                        fileStream.Position = this.metadataNcaOffset;
                        byte[] numArray = new byte[8192];
                        long num = this.metadataNcaSize;
                        while (true)
                        {
                            int num1 = fileStream.Read(numArray, 0, 8192);
                            int num2 = num1;
                            if (num1 <= 0 || num <= (long)0)
                            {
                                break;
                            }
                            fileStream1.Write(numArray, 0, num2);
                            num -= (long)num2;
                        }
                        fileStream.Close();
                        binaryReader.Close();
                        binaryWriter.Close();
                    }
                }

after that hacktool is used with the meta:
Code:
                if (File.Exists("meta"))
                {
                    Process process = new Process();
                    ProcessStartInfo processStartInfo = new ProcessStartInfo()
                    {
                        WindowStyle = ProcessWindowStyle.Hidden,
                        FileName = "hactool.exe",
                        Arguments = "-k keys.txt --romfsdir=data meta"
                    };
                    process.StartInfo = processStartInfo;
                    process.Start();
                    process.WaitForExit();
                    if (File.Exists("data\\control.nacp"))
                    {
                        byte[] numArray1 = File.ReadAllBytes("data\\control.nacp");
                        NACP.NACP_Datas[0] = new NACP.NACP_Data(numArray1.Skip<byte>(12288).Take<byte>(4096).ToArray<byte>());
                        for (int i = 0; i < (int)NACP.NACP_Strings.Length; i++)
                        {
                            NACP.NACP_Strings[i] = new NACP.NACP_String(numArray1.Skip<byte>(i * 768).Take<byte>(768).ToArray<byte>());
                            if (NACP.NACP_Strings[i].Check != 0)
                            {
                                this.CB_RegionName.Items.Add(this.Language[i]);
                                using (Bitmap bitmap = new Bitmap(string.Concat("data\\icon_", this.Language[i].Replace(" ", ""), ".dat")))
                                {
                                    this.Icons[i] = new Bitmap(bitmap);
                                }
                                this.PB_GameIcon.BackgroundImage = this.Icons[i];
                            }
                        }
                        this.TB_GameRev.Text = NACP.NACP_Datas[0].GameVer;
                        this.TB_ProdCode.Text = NACP.NACP_Datas[0].GameProd;
                        if (this.TB_ProdCode.Text == "")
                        {
                            this.TB_ProdCode.Text = "No Prod. ID";
                        }
                        File.Delete("meta");
                        Directory.Delete("data", true);
                    }
                    this.CB_RegionName.SelectedIndex = 0;
                    return;
                }

The file control.nacp contains the Titel ID and more.

Have a look at NACP.cs:

Code:
        public class NACP_String
        {
            public byte[] Data;
            public byte Check;
            public string GameName;
            public string GameAuthor;
            public NACP_String(byte[] data)
            {
                this.Data = data;
                this.Check = this.Data[0];
                this.GameName = Encoding.UTF8.GetString(this.Data.Take<byte>(512).ToArray<byte>());
                this.GameAuthor = Encoding.UTF8.GetString(this.Data.Skip<byte>(512).Take<byte>(256).ToArray<byte>());
            }
        }

As you can see, the GameName is at the very beginning of the file.

Does this help?
 

WolfThatGoesMoo

Active Member
Newcomer
Joined
Jun 1, 2018
Messages
43
Trophies
0
Age
39
XP
183
Country
United States
Cant wait to try it out
I'm attempting to make a thread but it keeps telling me that

Your content can not be submitted. This is likely because your content is spam-like or contains inappropriate elements. Please change your content or try again later. If you still have problems, please contact an administrator.

Please note if you are a NEW MEMBER you are unable to post any content that contains hyperlinks of any kind. Please ensure your post does not contain any links especially if you are quoting someone or replying to their post.

Do you have any ideas? There's no links in it. Just some screen shots and I've attached the file to the thread. Ohhh think the screen shots are considered links maybe

--- Edit ----

Okay, It was the screenshots and it's now fixed. It's up and ready for you to test if you'd like. Hope you enjoy!
 
Last edited by WolfThatGoesMoo,

Nollog

Well-Known Member
Member
Joined
Oct 10, 2008
Messages
2,964
Trophies
0
XP
1,327
Country
Ireland
checking the crc32 of each file (especially the larger sized files) takes forever, and in thus renaming an entire directory of games can take up to 15 minutes in my testing and I don't have very many games (I only grabbed backups I have physical copies of because I want digital versions.)
It's not something that a user should be doing daily, surely it doesn't matter if it's a once off scan.

You could do logic for skipping already processed files quite handedly.
 

WolfThatGoesMoo

Active Member
Newcomer
Joined
Jun 1, 2018
Messages
43
Trophies
0
Age
39
XP
183
Country
United States
It's not something that a user should be doing daily, surely it doesn't matter if it's a once off scan.

You could do logic for skipping already processed files quite handedly.

Very true, I'm sure the usage on this is sort of one time thing and yep, logic to skip it is already added to the release.
It's set up as an option called "Fast Mode", described on the post. It's an option so users can choose to quickly process the files, or to have it check the headers.
Try it out if you'd like! and thanks for the advice
 
  • Like
Reactions: Nollog

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    Veho @ Veho: Her boob is the cause of all this current shit :angry: