From a1f3a335d839f1bad2c4787fa6bb2ed6b98acb82 Mon Sep 17 00:00:00 2001 From: Alpha Chen Date: Sat, 22 Nov 2014 09:37:24 -0800 Subject: [PATCH] [bin] Add script for moving crosswords --- bin/archive_crosswords | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 bin/archive_crosswords diff --git a/bin/archive_crosswords b/bin/archive_crosswords new file mode 100755 index 0000000..c38d3f1 --- /dev/null +++ b/bin/archive_crosswords @@ -0,0 +1,21 @@ +#!/usr/bin/env ruby + +require 'fileutils' + +Dir[File.expand_path('~/Downloads/*.puz')].each do |puz| + crossword = File.basename(puz, '.puz') + dir = case crossword + when /av\d{6}/ + 'AV' + when /\d{3}[a-zA-Z]+/ + 'BEQ' + when /mgwcc\d{3}/ + 'MGWCC' + when /[A-Z][a-z]{2}\d{4}/ + 'NYT' + else + 'etc' + end + dir = File.expand_path("~/Dropbox/Shared/Crosswords/#{dir}") + FileUtils.mv puz, to, verbose: true +end