Search
 
SCRIPT & CODE EXAMPLE
 

RUBY

ruby file copy

require 'fileutils'
# Copy a file
FileUtils.cp 'myfile.txt', 'myfile.txt.bak'
# Copy list of files to folder
FileUtils.cp %w(somefile.txt another.txt), './bak'
FileUtils.cp Dir.glob('*.rb'), './bak', :verbose => true
Comment

ruby copy file

my_dir = Dir["C:/Documents and Settings/user/Desktop/originalfiles/*.doc"]
my_dir.each do |filename|
  name = File.basename('filename', '.doc')[0,4]
  dest_folder = "C:/Documents and Settings/user/Desktop/destinationfolder/#{name}/"
  FileUtils.cp(filename, dest_folder)
end
Comment

ruby file copy

file = File.open('text.txt', 'r')            # Opening file
copied_file = File.open('new_text.txt', 'w') # Creating new file
copied_file.puts(file.read)                  # Copying file
#                     Closing files
file.close
copied_file.close
#                        Testing
copied_file = File.open('new_text.txt', 'r') # Opening copied file
puts(copied_file.read)
# => What markets are called black? Those in Africa!
Comment

PREVIOUS NEXT
Code Example
Ruby :: installing ruby version using Rbenv 
Ruby :: ruby get current pid 
Ruby :: capitalize composed name ruby 
Ruby :: timeout in rails 
Ruby :: rails transactions 
Ruby :: rails cors allow all 
Ruby :: ruby delete first element of array 
Ruby :: rails console destroy all 
Ruby :: command to install ruby gems 
Ruby :: helper path outside view 
Ruby :: how works httparty ruby 
Ruby :: all rails g model types 
Ruby :: ruby deep copy 
Ruby :: object service 
Ruby :: ruby convert value to boolean 
Ruby :: check if the substring is present in the column of the record rails console 
Ruby :: ros2 publish message command line 
Ruby :: mobile money flutterwave payment 
Ruby :: ruby null 
Ruby :: rails add index from console 
Ruby :: rails format number k - m 
Ruby :: using module function in main ruby 
Ruby :: ruby convert array to set 
Ruby :: ruby on rails project 
R :: how to set a column as index r 
R :: glyph in r 
R :: r rename columns 
R :: turn matrix into dataframe r 
R :: ggplot2 black and white theme 
R :: convert na to 0 in r 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =