Created
July 24, 2015 16:10
-
-
Save anonymous/fa9cb9e53a8130d325b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
directory_name = %w[Original Modified] | |
directory_name.each do |dir| | |
if dir.exists?(directory_name) | |
abort("These folders already exist. No further action will be taken.") | |
else | |
Dir.mkdir(directory_name[0]) unless File.exists?(directory_name[0]) | |
Dir.mkdir(directory_name[1]) unless File.exists?(directory_name[1]) | |
end | |
end |
I assume you have a list of directory pairs. Each element of the directory_name array is an array of size 2 where the first element is original and the second is modified. Looks like these are path strings.
# For each pair of directories, check if they exist. If not, create them.
# The mkdir call will fail if the parent directories do not exist.
directory_name.each do |dpair|
Dir.mkdir(dpair[0]) unless File.exists?(dpair[0])
Dir.mkdir(dpair[1]) unless File.exists?(dpair[1])
end
directory_name.each do |dname|
Dir.mkdir(dname) unless File.exists?(dname)
end
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I assume you have a list of directory pairs. Each element of the directory_name array is an array of size 2 where the first element is original and the second is modified. Looks like these are path strings.