내가 여기에 여기에 나타났습니다 몇 가지 스크립트를 묶어하려고합니다 link text 사용자가 디렉토리 문자와 파일 확장명 주어진 문자를 이름을 바꾸거나 이름을 바꿀 수있는 기본 스크립트를 얻으려고 .빠른 루비 일괄 renamer
나는 모두 함께 묶는 데 어려움을 겪고 있습니다. 이것은 내가 지금까지있는 곳이다.
require 'fileutils'
define renamer(strip, stripdetails)
# So this is a strip function.
def strip(str,char)
new_str = ""
str.each_byte do |byte|
new_str << byte.chr unless byte.chr == char
end
new_str
end
# and then retrieve details from user.
#Get directory of files to be changed.
def stripdetails(strip myname)
puts "Enter Directory containing files"
STDOUT.flush
oldname = gets.chomp
puts "what characters do you want to remove"
str = gets.chomp
puts "what file extension do files end in?"
fileXt = gets.chomp
end
#And I found this from stackoverflow(I don't have enuff credits to post another hyperlink)
old_file = "oldname"
new_file = strip(oldname,str)
FileUtils.mv(old_file, new_file)
질문을 편집하고 작동하지 않는 사항을 설명하십시오. 어떤 오류가보고 있습니까, 아니면 예상대로 작동하지 않습니까? –