Skip to main content

A simple package to walk a directory tree and collect files and sizes into a SQLite DB.

Project description

Treewalker

A simple package to walk a directory tree and collect files and sizes into a SQLite DB.

Usage

For simple use cases, simply install the package from PyPI:

pip install treewalker

And run it from the command line:

treewalker --help
treewalker --output test.sqlite --path C:/temp

Usage and development

Get started (change directory to where you want the project first):

pip install treewalker

Run the script with your own .json configuration:

python treewalker.py --cfg my_config.json
{
    "output": "test.sqlite",
    "path": "c:/temp"
}

Or run the script entirely from the command line:

python treewalker.py --output test.sqlite --path c:\temp

Or build a single file executable if you need this to run on Windows systems that won't have Python pre-installed:

scripts/build_pyinstaller.bat c:/target/folder
scripts/build_pyinstaller_xp.bat c:/target/folder

This creates a treewalker.exe, which can be run 'anywhere':

.\treewalker.exe --output test.sqlite --path c:\temp

Note that the executable will be limited to running on systems that support the version of Python you're using to build it. I.e. for Windows XP (32-bit or 64-bit), the very latest version of Python you can use is 3.4.4.

Getting at the data

You can easily access the contents of any of the sqlite files:

from sqlite3 import connect

conn = connect('test.sqlite')
c = conn.cursor()
# show all the root directories
print(c.execute('SELECT * FROM dirs WHERE parent_dir<0').fetchall())
# show all files that have "test" in their name (case-insensitive)
print(c.execute('SELECT * FROM files WHERE name LIKE "%test%"').fetchall())

Look at the documentation of the Python standard sqlite3 library for more examples. https://docs.python.org/3/library/sqlite3.html

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

treewalker-0.0.12.tar.gz (10.1 kB view details)

Uploaded Source

File details

Details for the file treewalker-0.0.12.tar.gz.

File metadata

  • Download URL: treewalker-0.0.12.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7

File hashes

Hashes for treewalker-0.0.12.tar.gz
Algorithm Hash digest
SHA256 3ef4ff3512c1a566611c1203bdc958778e67a3127eb755bda80e8ec08c987a06
MD5 1ff33668b45e338c43b8743258b1eb40
BLAKE2b-256 b7efd8095b9783ce6d89fc539caeff2a32019667551ff4240744a3feae65f7e4

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page