Skip to content

Instantly share code, notes, and snippets.

@rtipton
Created July 18, 2016 18:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rtipton/b0fc7c05aee7c6cc41fb58f16fc35f11 to your computer and use it in GitHub Desktop.
Save rtipton/b0fc7c05aee7c6cc41fb58f16fc35f11 to your computer and use it in GitHub Desktop.
Reads contents of directory. Copies DSC1234 Elm Street - Bedroom 1.jpg to Elm Street - Bedroom 1.jpg Written and used for Hallway 2 Marketing real estate jobs
# Reads through a directory copying files like "DSC_1234 Elm Street - Bedroom 1.jpg" to "Elm Street - Bedrooom 1.jpg"
# Written and used for Hallway 2 Marketing real estate jobs
require 'FileUtils'
file_path = "C:\\_Transfer\\"
def cls
system('cls')
end
cls
# Building array of files in the directory
def fileList
Dir.entries('C:\_Transfer')
end
# Loop through the array setting file names and copying to new files
fileList.each do |fileNm|
if fileNm[0...3] == 'DSC'
puts "Copying " + fileNm + " => " + fileNm[9...60]
file1 = file_path + fileNm
file2 = file_path + fileNm[9...60]
FileUtils.cp(file1, file2)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment