Last active
August 29, 2015 14:09
Revisions
-
inz renamed this gist
Nov 14, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
inz created this gist
Nov 14, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ #!/usr/bin/env ruby require 'fileutils' MAPPING='dslab14-account-mapping.txt' FOLDER=ARGV.first || 'DSLab-Harvest-1237' TARGET=File.join('processed') Dir.mkdir(TARGET) rescue nil # Map users to immatriculation numbers. users = {} File.open(MAPPING, 'r') do |file| file.each do |line| parts = line.split next if parts.length < 5 user = parts[0] immatrnr = parts[4] users[user] = immatrnr end end Dir.new(FOLDER).each do |entry| user=entry.split('_').first next unless users.include?(user) base_path = File.join(FOLDER, entry) submission_filename = Dir.glob(File.join(base_path, "*.zip")).first next unless submission_filename # Rename to <immatr.nr>.zip puts "Copying from: #{submission_filename} to: #{File.join(TARGET, "#{users[user]}.zip")}" FileUtils.cp submission_filename, File.join(TARGET, "#{users[user]}.zip") end