This is how I am changing the directory path to the download folder.
Dir.chdir("C:/Users/abcd/Downloads/")
But this specific to a user. Is there is any way to make it more general?
This is how I am changing the directory path to the download folder.
Dir.chdir("C:/Users/abcd/Downloads/")
But this specific to a user. Is there is any way to make it more general?
The "C:/Users/abcd/Downloads/"
looks like the user directory for user abcd on windows. So I think this is a windows related question.
The Dir.home
on my Windows-PC is U:/
, not the user-directory.
But you can make use of ENV
:
Dir.chdir(File.join(ENV['USERPROFILE'], 'Downloads'))
Just to be aware of: This changes the directory for the rest of your script. There is also a block-version of Dir.chdir
.