Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9210493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:05:35+00:00 2026-06-18T01:05:35+00:00

Please find the below code: current_dir = Dir.pwd Dir.chdir(‘C:\Documents and Settings\Peter\My Documents\userdata\Downloaded Files’) current_dir

  • 0

Please find the below code:

current_dir = Dir.pwd
Dir.chdir('C:\Documents and Settings\Peter\My Documents\userdata\Downloaded Files')
current_dir = Dir.pwd

Dir.entries(current_dir)[2..-1].each do |dir|

  puts dir
  puts "-------"
  Dir.entries(dir)[2..-1].each do |d|

    #file_loc_dir =
    #File.rename(d, dir.concat(d))
    puts File.realdirpath(d ,dir)
    #puts dir.concat(d)

  end
  puts "-------"
end

Output:

C:\Documents and Settings\peter\My Documents\userdata\Ruby\Scripts>FileNamere
naming.rb
D07141
-------
C:/Documents and Settings/peter/My Documents/userdata/Downloaded Files/D07141
/Water lilies.jpg
C:/Documents and Settings/peter/My Documents/userdata/Downloaded Files/D07141
/Winter.jpg
-------
D07141101
-------
C:/Documents and Settings/peter/My Documents/userdata/Downloaded Files/D07141
101/Water lilies.jpg
C:/Documents and Settings/peter/My Documents/userdata/Downloaded Files/D07141
101/Winter.jpg

Confusion:

While puts dir gives D07141 and D07141101, File.realdirpath(d ,dir) gives the expanded directory name. Could you please clarify the logic?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T01:05:36+00:00Added an answer on June 18, 2026 at 1:05 am

    From the documentation:

    Returns the real (absolute) pathname of pathname in the actual
    filesystem. The real pathname doesn’t contain symlinks or useless
    dots.

    If dir_string is given, it is used as a base directory for
    interpreting relative pathname instead of the current directory.

    The last component of the real pathname can be nonexistent.

    (http://apidock.com/ruby/v1_9_3_125/File/realdirpath/class)

    It is expanded because that is what the method does. You aren’t calling puts on the dir inside of the #entries call, you are calling it on the return value of File.realdirpath, which, as discussed above, expands the passed in entry.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please find the below code <?xml version=1.0 encoding=utf-8?> <mx:Application xmlns:mx=http://www.adobe.com/2006/mxml layout=absolute> <mx:Script> <![CDATA[ [Bindable]
I am using File::Find in the code below to find the files from /home/user/data
Please find the code at http://jsfiddle.net/wlogeshwaran/NGL8P/4/ Here i want to make the 'hi' ,
I am using readDirSync to get the files from a Diretory. PLease find the
I wonder whether someone can help me please. I'm using the code below to
What is the maximum memory one application can use? Please find instrument screenshot with
I have one intresting requirement to achieve. could you please help? Please find the
Could you please help me find out the time complexity of the Fleury' algorithm
ereg and eregi functions will be deleted from Php. Please help to find alternatives
Please help me to find out error in my SQL query. I have created

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.