Created
April 13, 2015 21:11
-
-
Save ninjs/22ffa5dc995c6dddf5f0 to your computer and use it in GitHub Desktop.
This file contains 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 characters
require 'fileutils' | |
def help | |
print " | |
Hello there! Welcome to the Ruby File Mover. | |
Copy this script and the run.bat file into the working folder, then double click the run.bat file. | |
Usage: ruby #{__FILE__} | |
" | |
end | |
def file_op | |
dir = Dir.open(__dir__) | |
dir.each do |file| | |
if File.extname(file) != '.xlsx' | |
next if File.extname(file) != '.npi' | |
end | |
w = File.basename(file) | |
x = w.split(/ /)[0..1].join(' ') | |
y = '../' + x | |
z = y + '/' + w | |
print y | |
FileUtils.mkdir_p(y) | |
FileUtils.mv(file, z) | |
end | |
end | |
if ARGV.empty? | |
file_op | |
else | |
help | |
exit | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment