Skip to main content

SQL-like interface for querying files in your filesystem

Project description

File Query (fq)

A SQL-like interface for querying files in your filesystem.

Installation

# From PyPI
pip install file_query_tool

# Clone the repository
git clone https://github.com/nikdavis/file_query_tool.git
cd file_query_tool

# Install with pip
pip install -e .

# Or use UV
uv tool install .
# This will install the 'fq' command

Usage

Command Line

The quickest way to run file-query is with UV:

uv run python -m file_query_tool.cli "your query here"

After installation, you can use the shorthand command:

fq "your query here"

Basic Usage

# Find all Python files
fq "extension == 'py'"

# Find all text files and show their content
fq "extension == 'txt'" --show-content

Advanced Queries

File Query supports full SQL-like syntax:

# Find all Python files in the src directory
fq "SELECT * FROM 'src' WHERE extension == 'py'"

# Find all files larger than 100KB
fq "SELECT * FROM '.' WHERE size > 102400"

# Complex conditions
fq "SELECT * FROM '.' WHERE (extension == 'pdf' AND size > 1000000) OR (extension == 'txt' AND NOT name == 'README.txt')"

Query Syntax

File Query uses a SQL-like syntax:

SELECT * FROM 'directory_path' WHERE condition

Available Attributes

  • extension: File extension (without the dot)
  • name: Filename with extension
  • size: File size in bytes
  • path: Full file path

Operators

  • Comparison: ==, !=, <, <=, >, >=
  • Logical: AND, OR, NOT

Examples

# Find all PDF files
fq "extension == 'pdf'"

# Find all files not named "main.py"
fq "NOT name == 'main.py'"

# Find all large image files
fq "SELECT * FROM '.' WHERE (extension == 'jpg' OR extension == 'png') AND size > 500000"

# Find files with 'config' in their path
fq "path == '.*config.*'"

### Using wildcards with the LIKE operator

Find all Python files with "test" in their name:

fq "name LIKE '%test%.py'"


Find all files with a specific prefix:

fq "name LIKE 'config%'"


Find all markdown files in a specific year's folder:

fq "path LIKE '%/2023/%' AND extension == 'md'"


### Excluding files with NOT LIKE

Find all JavaScript files in src directory except those in lib folders:

fq "path LIKE 'src%' AND path NOT LIKE '%lib%' AND extension == 'js'"


Find all Python files that don't have "test" in their name:

fq "extension == 'py' AND name NOT LIKE '%test%'"

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

file_query_tool-0.1.12.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

file_query_tool-0.1.12-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file file_query_tool-0.1.12.tar.gz.

File metadata

  • Download URL: file_query_tool-0.1.12.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.2

File hashes

Hashes for file_query_tool-0.1.12.tar.gz
Algorithm Hash digest
SHA256 9233aecbd5e74d2e9d929f68fd74e1d531a0f5716abadf87e90cbc9d6a29fdc3
MD5 7c628df314eed1ef5edbd473b2049b2e
BLAKE2b-256 3a935e72a285b41196ed5a3203b17139b103e3febfd7349f639e68836d32cf0a

See more details on using hashes here.

File details

Details for the file file_query_tool-0.1.12-py3-none-any.whl.

File metadata

File hashes

Hashes for file_query_tool-0.1.12-py3-none-any.whl
Algorithm Hash digest
SHA256 78aacf6e3eaa74c11d4b9a5cd683a996dd146d7200a8bca4138490e6f2b1ee9b
MD5 df05a382369d1df401c6b5e03b21be01
BLAKE2b-256 984c7a5d088b708fd03132afdb0cfbb7a5ebfc7c8302b5f6b8528d43ad839031

See more details on using hashes here.

Supported by

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