01-List-Files-In-Folder_V01.qmd

Chapter-1-File-Organization-And-Backup

Author

Yahya Nazer - ChatBizDB.Com

Published

2026.06.18

Overview

1. Purpose

The File Listing Script is a comprehensive directory scanner designed to help users generate detailed reports of all files within a selected folder and its subfolders. This cross-platform tool creates both CSV and HTML reports with clickable hyperlinks, making it easy to navigate and analyze file structures.

Key Features:

  • Cross-platform compatibility (Windows, macOS, Linux)
  • Recursive directory scanning of all subfolders
  • Dual output formats (CSV and HTML)
  • Excel-compatible hyperlinks in CSV format
  • Browser-friendly clickable links in HTML format
  • Comprehensive file metadata including size, modification dates, and file types
  • GUI folder selection for ease of use
  • Automatic report organization with timestamped filenames

2. Inputs

System Requirements:

  • Python 3.6+ installed on your system
  • tkinter (usually included with Python installation)
  • Standard library modules (no additional installations required)

User Input:

The script requires only one input from the user:

  • Target folder selection via a graphical file dialog

Script Configuration:

The script automatically handles all other inputs:

  • Output directory creation (./report/ folder)
  • Timestamp generation for unique filenames
  • File metadata extraction
  • URL generation for hyperlinks

3. Steps

Step 1: Script Execution

python 01-list-files-in-folder-v01.py

Step 2: Folder Selection

  • A GUI dialog window will appear
  • Navigate to and select the folder you want to scan
  • Click “Select Folder” to confirm your choice
  • The script will scan the selected folder and all its subfolders

Step 3: Automatic Processing

The script will automatically:

  • Create a report folder in the same directory as the script
  • Scan all files recursively (including subdirectories)
  • Extract file metadata (size, modification date, creation date, file type)
  • Generate clickable file URLs
  • Skip hidden files (files starting with ._)

Step 4: Report Generation

  • Generate timestamped CSV file: 01-listing-YYYY-MM-DD--HH-MM.csv
  • Generate timestamped HTML file: 01-listing-YYYY-MM-DD--HH-MM.html
  • Save both files in the ./report/ directory

Step 5: Automatic File Opening

  • The HTML report will automatically open in your default web browser
  • The CSV file will be available in the report folder for manual opening

4. Outputs

Output Location:

All reports are saved in the ./report/ folder relative to the script location.

File Naming Convention:

  • CSV: 01-listing-YYYY-MM-DD--HH-MM.csv
  • HTML: 01-listing-YYYY-MM-DD--HH-MM.html

CSV File Output:

Contains 8 columns with the following information:

Column Description
Index Sequential file number
File Name Excel hyperlink formula for clickable file names
File Path Complete file path
File Size (bytes) File size in bytes
Date Modified Last modification timestamp
Date Created File creation timestamp
File Type File extension (e.g., pdf, txt, jpg)
Open Command OS-specific terminal command to open the file

HTML File Output:

Features a professional web interface with:

  • Summary section showing total files and generation timestamp
  • Sortable table with all file information
  • Clickable file links that open files in default applications
  • Responsive design with alternating row colors
  • File size formatting with thousand separators

Console Output:

The script provides detailed console feedback including:

  • Script information and version details
  • Processing status for each step
  • File count and location information
  • Success/error messages
  • Tips for using the generated reports

Usage Tips

For Excel Users:

  • Open the CSV file in Excel or Numbers
  • File names in column B are clickable hyperlinks
  • If hyperlinks don’t work, use the terminal commands in column H

For Browser Users:

  • The HTML file provides the best user experience
  • All file names are clickable and will open in default applications
  • Use browser search (Ctrl+F) to find specific files

For Advanced Users:

  • Modify the print_flag variable to control console output verbosity
  • The script can be easily integrated into automated workflows
  • Output files are UTF-8 encoded for international character support

Troubleshooting:

  • Ensure Python 3.6+ is installed
  • Check that tkinter is available (usually included with Python)
  • If GUI doesn’t appear, try running from command line
  • For permission errors, ensure write access to the script directory

Technical Notes

  • Hidden files starting with ._ are automatically skipped
  • File URLs are generated using proper OS-specific formats
  • Timestamps use ISO format: YYYY-MM-DD HH:MM:SS
  • Error handling includes graceful fallbacks for inaccessible files
  • Memory efficient processing suitable for large directory structures ## Contact Us

Resources & Downloads

Download all Python scripts and resources from this book:

www.chatbizdb.com/python-book

All code examples, templates, and additional materials are available for download. Please do not share this link - Thank you.

Copyright © 2025 ChatBizDB.com. All rights reserved.


No part of this publication may be reproduced, distributed, or transmitted in any form or by any means, including photocopying, recording, or other electronic or mechanical methods, without the prior written permission of the publisher, except in the case of brief quotations embodied in critical reviews and certain other noncommercial uses permitted by copyright law.


For permission requests, write to the publisher at: Email us

Contact Us

If you have any question or comment please contact us at Email us and make sure you add python-book at the beginning of the subject.

[1] "Time taken to run the Quarto document: 0.0996799468994141 seconds"