Created
January 5, 2014 04:08
-
-
Save Zyber17/8264230 to your computer and use it in GitHub Desktop.
A [Maid](https://github.com/benjaminoakes/maid) rule for 'moving' folders and their files. (Only works if there are no subdirectories.)
This file contains hidden or 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
rule 'Move folders from one directory to another' do | |
folder_destination = '[the path of the directory to where we want the folder moved]' | |
if File.directory?(folder_destination) #Let's make sure that the directory we want to move the folder to exists | |
dir('[the direcotry where we are getting the folder from]').each do |folder| #Let's grab all the potential folders | |
if File.directory?(folder) #Let's check and see if this item is a folder | |
file_destination = folder_destination + File.basename(folder) #Let's get the path to the folder we're about to create | |
mkdir(file_destination) #We need to make the 'moved' folder where we're going to put the files from the original folder | |
move(dir("#{folder}/*"), file_destination) #Now we can move the files | |
trash(folder) #Finally, let's trash the original folder | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment