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 (and most) use cases, simply install the package from PyPI:

pip install treewalker

And run it from the command line:

treewalker --help
treewalker --db test.sqlite --walk C:/temp

This is the preferred and recommended way to run Treewalker.

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
{
    "database": "test.sqlite",
    "walk": "c:/temp"
}

Or run the script entirely from the command line:

python treewalker.py --db test.sqlite --walk 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 --db test.sqlite --walk 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 and at the documentation of Treewalker at https://treewalker.readthedocs.io

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.1.10.tar.gz (13.3 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: treewalker-0.1.10.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for treewalker-0.1.10.tar.gz
Algorithm Hash digest
SHA256 acd4aecd7eb1ef4caa722bc544abfab54a2b88daad3112f3e622c0b89c3e9649
MD5 49411720bfaaa1ca360c760eb716c563
BLAKE2b-256 3c3409d4dc58c19cf04d2a981929400c5fba16387b1420c734ab0aa5176b7abb

See more details on using hashes here.

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