Skip to content

Instantly share code, notes, and snippets.

@robi42
Created March 12, 2010 16:31
Show Gist options
  • Save robi42/330483 to your computer and use it in GitHub Desktop.
Save robi42/330483 to your computer and use it in GitHub Desktop.
include('fs-base');
var format = require('ringo/utils').format;
const ROOT = './20news-18828';
const MAX_FILES = 100;
list(ROOT).forEach(function (dir) {
print('Dir:', dir);
while (list(format('{}/{}', ROOT, dir)).length > MAX_FILES) {
for each (var file in list(format('{}/{}', ROOT, dir))) {
if (list(format('{}/{}', ROOT, dir)).length == MAX_FILES) break;
if (Math.random() >= 0.5) {
print('Removing:', file);
remove(format('{}/{}/{}', ROOT, dir, file));
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment