Guest User

Untitled

a guest
Apr 14th, 2017
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 0.66 KB | None | 0 0
  1. #!/usr/bin/env rdmd
  2. import std.stdio;
  3. import std.file;
  4. import std.algorithm.iteration;
  5. import std.regex;
  6. import std.array;
  7. import std.typecons;
  8.  
  9. void move(string subfolder, string filename) {
  10.     if (!subfolder.exists) {
  11.         mkdir(subfolder);
  12.     }    
  13.     auto target = subfolder ~ "/" ~ filename;
  14.     rename(filename, target);
  15. }
  16.  
  17. void main() {
  18.     static ss = ctRegex!(`^\w+SS\w+\.avi$`);
  19.  
  20.     dirEntries(getcwd, SpanMode.shallow)
  21.         .filter!(a => a.isFile)
  22.         .map!(a => std.path.baseName(a.name))
  23.         .filter!(a => !a.matchFirst(ss).empty)
  24.         .map!(a => tuple(a.splitter(`SS`).front, a))
  25.         .each!(a => move(a.expand));
  26. }
Advertisement
Add Comment
Please, Sign In to add comment