[Release] py3DSorter: ROM sorter for GW/MT Card

Discussion in '3DS - Homebrew Development and Emulators' started by storm75x, Feb 12, 2015.

  1. storm75x
    OP

    storm75x Remember that thing I don't remember? Yeah, that!

    Member
    633
    823
    Jan 3, 2015
    __̴ı̴̴̡̡̡ ̡͌l̡̡̡ ̡͌l̡*̡̡ ̴̡ı̴̴̡ ̡̡͡|̲͡ ̲__
    py3DSorter 1.01
    [​IMG]

    This is a simple but effective standalone Python scripts that allows you to sort 3DS ROMS on Gateway/MT Micro SD Cards.

    Requirements
    Python 3.4 or above

    Instructions
    Download and run py3DSorter.exe for Windows users. For non-Windows users however, extract the scripts attached to this thread and run it from Python IDLE 3.4, tkinter could not be ran normally.

    Editing the scripts is allowed but don't forget to credit.

    Big thanks to Mthodmn101 on Maxconsole for compiling it for Windows.
    Download for Windows here: https://www.mediafire.com/?0mtwjw684n33154

    As seen on MaxConsole.
     

    Attached Files:

  2. nosklo

    nosklo Member

    Newcomer
    49
    14
    Oct 16, 2010
    Brazil
    Thanks, it seems it works by creating a temporary folder, and moving all files inside it, and then moving them back in desired order.

    My issue is that it seems to move each file inside the temp dir and back again, before starting the next file, so it will return to the same FAT entry and won't change the order!

    I would change:

    Code:
                    for line in range(len(tmp_files)):
                        shutil.move(dir+tmp_files[line],dir+".temp_gw/"+tmp_files[line])
                        shutil.move(dir+".temp_gw/"+tmp_files[line],dir+tmp_files[line])
    
    To:

    Code:
                    for filename in tmp_files:
                        shutil.move(os.path.join(dir, filename),os.path.join(dir, ".temp_gw", filename))
                    for filename in tmp_files:
                        shutil.move(os.path.join(dir, ".temp_gw", filename), os.path.join(dir, filename))
    
    That way it moves all files to the temp dir first, and then move back in order.

    Another suggestion is to use os.path.join function to join paths, it works better than using +
     
    storm75x likes this.
  3. Rinnegatamante

    Rinnegatamante GBAtemp Psycho!

    Member
    3,127
    3,270
    Nov 24, 2014
    Italy
    Bologna
  4. nosklo

    nosklo Member

    Newcomer
    49
    14
    Oct 16, 2010
    Brazil
    Have you tried? Touching the file doesn't seem to change its position in the gateway menu here... Only moving it around does the trick.
     
  5. Rinnegatamante

    Rinnegatamante GBAtemp Psycho!

    Member
    3,127
    3,270
    Nov 24, 2014
    Italy
    Bologna
    MMhhh i'll try to make it without moving and i'll see if i get it.
     
  6. storm75x
    OP

    storm75x Remember that thing I don't remember? Yeah, that!

    Member
    633
    823
    Jan 3, 2015
    __̴ı̴̴̡̡̡ ̡͌l̡̡̡ ̡͌l̡*̡̡ ̴̡ı̴̴̡ ̡̡͡|̲͡ ̲__
    Thank you for a feedback, I have implemented the change. This looks like a more refined way of doing things, however, I couldn't help but notice that it takes a split of a second longer to complete the operation.
     
  7. nosklo

    nosklo Member

    Newcomer
    49
    14
    Oct 16, 2010
    Brazil
    Are you sure? How did you measure? It shouldn't take longer, as the number of operations is the same in the end - only the order changed.
     
  8. Rinnegatamante

    Rinnegatamante GBAtemp Psycho!

    Member
    3,127
    3,270
    Nov 24, 2014
    Italy
    Bologna
    Ok, i tested all possible file attributes changing and it seems that GW uses the same Sorting algorithm of GetFiles() func of .NET Framework 3.5 [ https://msdn.microsoft.com/en-us/library/4cyf24ss(v=vs.110).aspx ] so i don't know why but only physically deleting the file and replacing it could change their loading order. :/
    Anyway, doing my tests, i create a quite similar program to py3DSorter in VB.Net.
    If someone installed Microsoft .NET Framework 3.5 and doesn't want to install Python 3.4 just grab it here: https://mega.co.nz/#!oJ4kSLpB!b6d6k2TXISye7VpD-CuvKOtBLjrPGKOTgPurFue9sjE
    [​IMG]
     
  9. nosklo

    nosklo Member

    Newcomer
    49
    14
    Oct 16, 2010
    Brazil
    You don't have to delete the file. Just moving all files to a separate folder and moving them back in order does the trick. It is also faster than a copy, since the data is not actually moved, only the name of the file in the allocation table gets changed, so it is really fast.
     
  10. Rinnegatamante

    Rinnegatamante GBAtemp Psycho!

    Member
    3,127
    3,270
    Nov 24, 2014
    Italy
    Bologna
    By deleting i want to say this infact Gateway Sorter use the same method to update sorting list.
     
  11. storm75x
    OP

    storm75x Remember that thing I don't remember? Yeah, that!

    Member
    633
    823
    Jan 3, 2015
    __̴ı̴̴̡̡̡ ̡͌l̡̡̡ ̡͌l̡*̡̡ ̴̡ı̴̴̡ ̡̡͡|̲͡ ̲__
    Updated with an executable file.
     
  12. yoshinatsu

    yoshinatsu GBAtemp Fan

    Member
    378
    174
    Sep 14, 2009
    Greece
    Downtown Jigoku
    Finally, a sorting tool that works!! I've wanted this for a long time.
     
  13. storm75x
    OP

    storm75x Remember that thing I don't remember? Yeah, that!

    Member
    633
    823
    Jan 3, 2015
    __̴ı̴̴̡̡̡ ̡͌l̡̡̡ ̡͌l̡*̡̡ ̴̡ı̴̴̡ ̡̡͡|̲͡ ̲__
    Glad it helped out. Sorting was a bane to me too.
     
  14. Xenon Hacks

    Xenon Hacks GBAtemp Guru

    Member
    7,071
    3,384
    Nov 13, 2014
    United States
    Love this tool thank you so much
     
  15. Leslie White

    Leslie White GBAtemp Regular

    Member
    228
    84
    Feb 21, 2015
    France
    Paris
    Works like a charm ! Thanks
     
  16. storm75x
    OP

    storm75x Remember that thing I don't remember? Yeah, that!

    Member
    633
    823
    Jan 3, 2015
    __̴ı̴̴̡̡̡ ̡͌l̡̡̡ ̡͌l̡*̡̡ ̴̡ı̴̴̡ ̡̡͡|̲͡ ̲__
    Hmm maybe I should make a universal ROM tool that sorts and do whatever.
    And this time, I will actually code in my comfortable coding language. :P