Is it possible to find/get the complete path of a directory by
specifying the
directory name as which drive it is in? For example
I’ve a directory on drive as D:\abc\efg\screenshots\
I want to find the complete path of the directory screenshots, not sure
on which drive it exists, may be C: or D: or E: but the parent folder
starts with abc\efg\screenshots\
Apreciate response
Thx,
#M
On Tue, Oct 29, 2013 at 9:17 PM, shaik s. [email protected] wrote:
Apreciate response
Thx,
#M
assuming working directory is /tmp .
File.expand_path “whatever” # => “/tmp/whatever”
File.absolute_path “whatever” # => “/tmp/whatever”
$ ln -s /tmp/whatever /tmp/1 # make a symlink
File.expand_path “1” # => “/tmp/1”
File.absolute_path “1” # => “/tmp/1”
File.realpath “1” => “/tmp/whatever”
I didn’t try this on windows platform, If you don’t want the drive, you
could try
‘D:\hello\world’.gsub(/^\w+:\/, ‘’)
correct my if directory separator char for ruby on windows is ‘/’ .
–
Silence is golden.
twitter: @AccelReality
wikipedia: AleiPhoenix
blog: weblog.areverie.org
wiki: wiki.areverie.org