Created
April 13, 2016 20:05
-
-
Save phwelo/2c91e9561044e5eec2d237c5e488eae1 to your computer and use it in GitHub Desktop.
Ruby function to find first available single-letter drive letter on a windows system
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
def findADriveLetter() | |
reverseAlphabet = ["Z", "Y", "X", "W", "V", "U", "T", "S", "R", "Q", "P", "O", "N", "M", "L", "K", "J", "I", "H", "G", "F", "E", "D", "C", "B", "A"] | |
reverseAlphabet.each { |letter| | |
if File.exist?("#{letter}:\\") | |
return letter | |
break | |
end | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment