그래서 우리는 우리가 얻는 보고서를 구성하기위한 파일 설정을하기 위해 다음과 같은 작은 스크립트를 가지고 있습니다.Ruby를 사용하여 큰 디렉토리 시스템 자동화
#This script is to create a file structure for our survey data
require 'fileutils'
f = File.open('CustomerList.txt') or die "Unable to open file..."
a = f.readlines
x = 0
while a[x] != nil
Customer = a[x]
FileUtils.mkdir_p(Customer + "/foo/bar/orders")
FileUtils.mkdir_p(Customer + "/foo/bar/employees")
FileUtils.mkdir_p(Customer + "/foo/bar/comments")
x += 1
end
모든 것이 while
전에 작동하는 것 같다,하지만 난 점점 계속 :
'mkdir': Invalid argument - Cust001_JohnJacobSmith(JJS) (Errno::EINVAL)
CustomerList.txt
에서 첫 번째 라인이 될 것이다. 문자열로 간주되기 위해 배열 항목에 뭔가를해야합니까? 변수 유형이나 다른 것이 일치하지 않습니까?
미리 감사드립니다.
왜 고객은 일정합니까? – inger
은 첫 번째 줄의 "Cust001_JohnJacobSmith (JJS)"입니까? – inger
예, 파일의 첫 줄입니다. – JHStarner