Skip to content

Instantly share code, notes, and snippets.

@ninjs
Created April 13, 2015 21:11
Show Gist options
  • Save ninjs/22ffa5dc995c6dddf5f0 to your computer and use it in GitHub Desktop.
Save ninjs/22ffa5dc995c6dddf5f0 to your computer and use it in GitHub Desktop.
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