Skip to content

Commit

Permalink
fuzzy: New script to fuzzy-match file names and rename (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosuav committed Aug 14, 2016
1 parent 56756a5 commit 1379df3
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions fuzzyname.pike
@@ -0,0 +1,13 @@
int main(int argc, array(string) argv)
{
mapping args = Arg.parse(argv);
int dryrun = !args->rename; //Dry run is the default.
array(string) newnames = Stdio.read_file(args[Arg.REST][0])/"\n" - ({""});
foreach (args[Arg.REST][1..], string fn)
{
sort(String.fuzzymatch(newnames[*], fn), newnames);
if (dryrun) write("mv %O %O\n", fn, newnames[-1]);
else mv(fn, newnames[-1]);
newnames = newnames[..<1];
}
}

0 comments on commit 1379df3

Please sign in to comment.