import os
import openpyxl
# Specify the target folder
folder_path = "C:/Your/Target/Folder" # Replace with the actual path
# Create a new Excel workbook
workbook = openpyxl.Workbook()
sheet = workbook.active
# Set column headers
sheet['A1'] = 'Serial Number'
sheet['B1'] = 'Path'
sheet['C1'] = 'Folder Name'
sheet['D1'] = 'File Name'
# Assign a unique serial number to each file
row_num = 2 # Start writing data from row 2
def list_files(path):
global row_num
for root, directories, files in os.walk(path):
for file in files:
full_path = os.path.join(root, file)
folder_name = os.path.basename(root)
sheet.cell(row=row_num, column=1).value = row_num - 1 # Serial number
sheet.cell(row=row_num, column=2).value = full_path
sheet.cell(row=row_num, column=3).value = folder_name
sheet.cell(row=row_num, column=4).value = file
row_num += 1
list_files(folder_path)
# Save the Excel workbook
workbook.save("file_list.xlsx") # Adjust the filename as needed
i am presenting here, what are all i am reading and what are all experiences which I got. i am just sharing here. வணக்கம்....நான் விவேக்.. இங்கு எனக்கு கிடைத்த தகவலும் .. என்னை கவர்ந்த செய்திகளும் உங்களுக்கு தருகின்றேன் ...
Wednesday, March 13, 2024
How to Get files from the directory - One more method
Subscribe to:
Posts (Atom)
How to Get files from the directory - One more method
import os import openpyxl # Specify the target folder folder_path = "C:/Your/Target/Folder" # Replace with the actual path # Cre...
-
http://podian.blogspot.com/ One of the Good blog in Tamil so you can read current news also.
-
ஸ்ரீ இராம நாம மந்திர மகிமை 🌷 1. நமக்கு நன்மை வரவேண்டுமானால் 'ராம நாமத்தை இடைவிடாமல் கூறவேண்டும். நமது ஒவ்வொரு மூச்சும் ...