Powered by Blogger.

Social Icons

Featured Posts

Showing posts with label directory. Show all posts
Showing posts with label directory. Show all posts

List all files in a Directory in Python

Wednesday, February 22, 2023

import os

directory_path = "/path/to/directory"

#For windows
directory_path = "C:\\path\\to\\directory"

file_list = os.listdir(directory_path)

print("List of files in directory:")
for file_name in file_list:
    print(file_name)

Create directory list from command prompt on Windows

Tuesday, July 11, 2017

Navigate to folder and run following command

dir > FileName.txt
or
dir > Complete Folder Path/Filename.txt

dir >> Filename.txt will append data to existing file 

dir /s > FileName.txt will include sub-directories

dir /b > Filename.txt will save in Bare format

For more options run dir /?
 

Translate

Popular Posts