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
# Clone the repository
git clone https://github.com/yourusername/file-query.git
cd file-query
# Install with pip
pip install -e .
# Or use UV
uv run python -m src.cli "your query"
# Install as a permanent tool with 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 src.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 extensionsize: File size in bytespath: 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file file_query_text-0.1.11.tar.gz.
File metadata
- Download URL: file_query_text-0.1.11.tar.gz
- Upload date:
- Size: 13.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c42e58d2239555b778d9d84d9c8cae5a4a060648aa180b17cb0eaa1da886c28
|
|
| MD5 |
35883252f7bb07f421e3b9dd22162484
|
|
| BLAKE2b-256 |
097e664a9204e26e2c3d3cb24be588aefd7ec2cdf7c834ca5b04dfeb339567a7
|
File details
Details for the file file_query_text-0.1.11-py3-none-any.whl.
File metadata
- Download URL: file_query_text-0.1.11-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ce246b38233839307a6ad68978fe9fe2221112d1041549b9a49f3820551912f
|
|
| MD5 |
9fd36cda4e189bf5fc1db8839f2ff501
|
|
| BLAKE2b-256 |
5ad3ee56bb442631c70de961256a94a2f47d0567974dda1e54cdec428c51fe96
|