here is the code
dirArray = Dir.entries(".")
Dir.mkdir “SMITH, JOHN X755055”
dirArray.each do
fileentry = dirArray.pop
if fileentry.match(“txt”)
textfile = File.open(fileentry)
textfile.each_line {|line|
newdir = line.upcase.to_s
if !File.exist?(newdir)
Dir.mkdir “#{newdir}”
print "Created directory: " + newdir +
“\n”
else
print “Directory " + newdir + " already
exists…
.\n”
end
}
end
end
i have a text file in the same directory
it has two lines, they look like this:
SMITH, ADAM X755077
SMITH, ADAM X755078
when I run the above script, the first Dir.mkdir works fine
however when it reads the first line of the text file, the
Dir.mkdir “#{newdir}” doesn’t create a directory
i get this error
mkdirs.rb:9:in mkdir': Invalid argument - "SMITH, ADAM X755077" (Errno::EIN VAL) from mkdirs.rb:9 from mkdirs.rb:6:in
each_line’
from mkdirs.rb:6
from mkdirs.rb:2:in `each’
from mkdirs.rb:2
what am I doing wrong