diff --git a/binaries/data/xmbcleanup.bat b/binaries/data/xmbcleanup.bat new file mode 100644 index 0000000000..27d58d3024 --- /dev/null +++ b/binaries/data/xmbcleanup.bat @@ -0,0 +1,3 @@ +@echo off +cd ..\..\build\bin +..\xmbcleanup\xmbcleanup.exe \ No newline at end of file diff --git a/build/xmbcleanup/xmbcleanup.exe b/build/xmbcleanup/xmbcleanup.exe new file mode 100644 index 0000000000..3fb5d8b558 Binary files /dev/null and b/build/xmbcleanup/xmbcleanup.exe differ diff --git a/build/xmbcleanup/xmbcleanup.pl b/build/xmbcleanup/xmbcleanup.pl new file mode 100644 index 0000000000..c974b42eca --- /dev/null +++ b/build/xmbcleanup/xmbcleanup.pl @@ -0,0 +1,52 @@ +use strict; +use warnings; + +use File::Find; + +++$|; + +# Relative to build/bin or build/xmbcleanup +my $dir = '../../binaries/data/mods/official'; + +my @xmlfiles; +find({ + wanted => sub { push @xmlfiles, $File::Find::name if /\.xml$/; $File::Find::prune=1 if $_ eq '.svn' }, + }, $dir); + +my $count = 0; + +# First, delete old-style XMB files +for (@xmlfiles) { + # Turn "etc.xml" into "etc.xmb" + (my $f = $_) =~ s/\.xml$/.xmb/ or die "Internal error: invalid filename '$_'"; + # If it exists, delete it + if (-e $f) { + print "Deleting $f\n"; + unlink $f; + ++$count; + } +} + +for (@xmlfiles) { + # Turn "etc.xml" into "etc_<'?' x 17>.xmb" + (my $f = $_) =~ s/\.xml$/_?????????????????.xmb/ or die "Internal error: invalid filename '$_'"; + $f =~ s/ /\\ /g; + + # Find all such files + my @xmbfiles = glob $f; + + # If there are two or more, delete all but the newest + if (@xmbfiles > 1) { + @xmbfiles = sort @xmbfiles; # files are "etc_xmb", with TIMESTAMP + # hex-encoded, so sorting will put the oldest files first. + # Remove the newest + pop @xmbfiles; + # Delete the rest + print "DELETING @xmbfiles\n"; + unlink @xmbfiles; + $count += @xmbfiles; + } +} + +print "\n\nCompleted - $count ".($count==1?'file':'files')." deleted. Press enter to exit."; +<> \ No newline at end of file