Skip to content

Commit d89ebac

Browse files
committed
Implemented --undupe-rename
1 parent ef0fc74 commit d89ebac

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

nsz.sln

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.30611.23
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "nsz", "nsz.pyproj", "{39FABC12-415B-4DEB-BFAE-38AC2D1FC72C}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{39FABC12-415B-4DEB-BFAE-38AC2D1FC72C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{39FABC12-415B-4DEB-BFAE-38AC2D1FC72C}.Release|Any CPU.ActiveCfg = Release|Any CPU
16+
EndGlobalSection
17+
GlobalSection(SolutionProperties) = preSolution
18+
HideSolutionNode = FALSE
19+
EndGlobalSection
20+
GlobalSection(ExtensibilityGlobals) = postSolution
21+
SolutionGuid = {0DA4C9E6-8453-4BC1-8767-77E66EDEF7B6}
22+
EndGlobalSection
23+
EndGlobal

nsz/ParseArguments.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def parse():
2626
parser.add_argument('--titlekeys', action='store_true', default=False, help="Extracts titlekeys from your NSP/NSZ files and adds missing keys to ./titlekeys.txt and JSON files inside ./titledb/ (obtainable from https://github.com/blawar/titledb). Titlekeys can be used to unlock updates using NUT OG (OG fork obtainable from https://github.com/plato79/nut). There is currently no publicly known way of optioning NSX files. To MitM: Apply disable_ca_verification & disable_browser_ca_verification patches, use your device's nx_tls_client_cert.pfx (Password: switch, Install to OS and import for Fiddler or import into Charles/OWASP ZAP). Use it for aauth-lp1.ndas.srv.nintendo.net:443, dauth-lp1.ndas.srv.nintendo.net:443 and app-b01-lp1.npns.srv.nintendo.net:443. Try with your WiiU first as there you won't get banned if you mess up.")
2727
parser.add_argument('--undupe', action='store_true', help="Deleted all duplicates (games with same ID and Version). The Files folder will get parsed in order so the later in the argument list the more likely the file is to be deleted")
2828
parser.add_argument('--undupe-dryrun' , action='store_true', help="Shows what files would get deleted using --undupe")
29+
parser.add_argument('--undupe-rename' , action='store_true', help="Renames files to minimal standard")
2930
parser.add_argument('--undupe-prioritylist', type=str, default="", help='Regex specifying which dublicates delegtion should be prioritized before following the normal deletion order. Example: "^.*\.(nsp|xci)$"')
3031
parser.add_argument('--undupe-whitelist', type=str, default="", help='Regex specifying which dublicates should under no circumstances be deleted. Example: "^.*\.(nsz|xcz)$"')
3132
parser.add_argument('--undupe-blacklist', type=str, default="", help='Regex specifying which files should always be deleted - even if they are not even a dublicate! Be careful! Example: "^.*\.(nsp|xci)$"')

nsz/undupe.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,18 @@ def undupe(args):
7474
os.remove(version_value[0])
7575
Print.info("[DELETED] [DUPE]: " + version_value[0])
7676
Print.info("Keeping " + file)
77+
if args.undupe_rename:
78+
for file in version_value:
79+
if not isOnWhitelist(args, file):
80+
newName = str(Path(file).parent.joinpath("["+titleID_key+"][v"+str(version_key)+"].nsz"))
81+
if file == newName:
82+
#Print.info("[RENAME] [SKIPPED] " + newName)
83+
pass
84+
elif Path(newName).is_file():
85+
Print.info("[RENAME] [ERROR_ALREADY_EXIST] " + newName)
86+
else:
87+
if args.undupe_dryrun:
88+
Print.info("[DRYRUN] [RENAME]: " + "os.rename(" + file + ", " + newName)
89+
else:
90+
Print.info("[RENAME]: " + "os.rename(" + file+ ", " + newName)
91+
os.rename(file, newName)

0 commit comments

Comments
 (0)