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 :: time loop start with non zero in ruby 
Ruby :: logstash-logger gem 
Ruby :: ruby String split second parameter 
Ruby :: rails rspec test email sent 
Ruby :: record count by month in rails 
Ruby :: how to run one line pry 
Ruby :: class ruby 
Ruby :: division in ruby 
R :: r define nested empty list 
R :: R string ascii accents 
R :: delete first three lines dataframe R 
R :: i have library(dplyr) but i still get Error in select(., 
R :: r split string column by delimiter 
R :: sort R 
R :: how to find the R packages and versions 
R :: r - remove NA 
R :: switch in r 
R :: how to read in txt/csv files into r 
R :: convert string to lowercase R 
R :: R squared regression in r with ggplot 
R :: How to remove rows with inf from a dataframe in R 
R :: make the first row as header in r 
R :: summary metrics of confusion matrix 
R :: ggplot glm 
R :: geom_boxplot line width 
R :: extract residual standard error from lm in r 
R :: save link tweet in new column in R 
R :: digits in format and formatc in r 
Rust :: rust field is never read remove warning 
Rust :: rust .0 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =