Guest User

Untitled

a guest
Dec 12th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.54 KB | None | 0 0
  1. File.open('result.txt','w') do |f| #Make new file name result.txt
  2.     path = "C:\\Users\\eucharis\\Desktop" #Your Path
  3.     shellscript = `dir /s #{path} |find "File(s)"` #Run Shell Command and Select Target Lines
  4.     result = shellscript.split("File(s)").last.to_s #Split Lines to Array And Select Last Line And Convert to String
  5.     result = result.sub(/bytes/,'').sub(/ /,'') #Remove 'bytes' and empty string in Result
  6.     until result.scan(/,/).count.to_i <= 0 do #Loop for remove ',' in Result
  7.         result = result.sub(/,/,'')
  8.     end
  9.     f.puts(result) #Write File
  10. end
Add Comment
Please, Sign In to add comment