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

  • SEARCH
  • Home
  • 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 7582385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:25:22+00:00 2026-05-30T18:25:22+00:00

I am looking for a code in python that allows me to take a

  • 0

I am looking for a code in python that allows me to take a directory and create a list similar to “ls –lR” containing all the files in the dir. and sub-dir. in a tabular form with their names, size, date last modified, permissions, users etc.

And also the total size of all the files in the directories and sub-directories.

I have used stats as of now, for the time, size and permissions and have appended the same in lists of which I have made tables. But to find the file name, the perm, owner and group. If I could get a neater code?

  • 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-05-30T18:25:24+00:00Added an answer on May 30, 2026 at 6:25 pm

    If you are using python 2.x you can use :

    commands.getoutput("ls –lR") 
    

    for python 3.0 you can try :

    subprocess.check_output("ls -lR")
    

    Hope it helps!

    EDIT

    Commands.getoutput and subprocess.check_output will return the output from the command you used as parameter.

    Ex:

    lslr = commands.getoutput("ls –lR") 
    print lslr
    

    This will give you exactly the same output as ls -lR in your current dir. Then it’s up to you to filter whatever you need from there!

    To change current dir use os.chdir(/desired/dir).

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

Sidebar

Related Questions

I'm looking for Python code that removes C and C++ comments from a string.
Looking at Python modules and at code in the lib-dnyload directory in the Python
I'm looking for python modules that can help with grepping C++ code. I have
I'm looking at existing python code that heavily uses Paramiko to do SSH and
I'm looking into speeding up my python code, which is all matrix math, using
I was looking at the following code in python: for ob in [ob for
I need to rewrite some Perl code in python. So I'm looking for the
I need to use a priority queue in my Python code, and: am looking
I'm looking for a Ruby's equivalent of Code Like a Pythonista: Idiomatic Python Desirable
I'm interested in speed, not good looking code, that is why I'm using array

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.