npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@sortql/sortql-cli

v1.3.1

Published

A file management automation tool with SQL-like syntax

Downloads

26

Readme

About

sortQL is a simple, yet powerful, file management automation tool that offers a rich toolset of rule-based operations using a declarative SQL-like syntax. It's designed to help you automate workflows, such as moving, copying, deleting, and archiving files, based on predefined conditons.

Features include:

  • Simple Installation: Install globally and run from any directory using npx.

  • Declarative Syntax: Define complex file and folder operations in a simple, readable .SQL file.

  • Watch Mode: Automatically re-run the queries whenever a file or folder is added, removed, or modified.

  • Cross-Platform: Works seamlessly across different operating systems, including Windows, macOS, and Linux.

  • Open-Source: Fully open-source codebase, allowing you to contribute and modify the source code.

https://github.com/leonmeka/sortql-cli/assets/15350962/5e9abf95-5d9f-41e5-bc6c-896019a73a88

Example: Automated workflow for cleaning up the mess on your desktop.

How it Works

At the heart of sortQL is the queries.sql file, which contains a set of operations to be executed. Each operation is defined in a single line, which specifies the type of operation, the files or directories to be affected, and the conditions that must be met. Users, who are already worked with SQL, will find the syntax familiar.

Here's an example of a queries.sql file, which moves files with specific extensions into respective subfolders:

-- Move documents to a different subfolder
MOVE 'files' FROM '' WHERE 'extension' LIKE '(docx|doc|pdf)' TO 'documents'
MOVE 'files' FROM '' WHERE 'extension' LIKE '(pptx|ppt)' TO 'presentations'
MOVE 'files' FROM '' WHERE 'extension' LIKE '(xlsx|xls)' TO 'spreadsheets'

For more information on how to use sortQL, please refer to the documentation.

Quick Start

Prerequisites

Before you begin, ensure you have installed Node.js (<= v.20.11.1 TLS) on your machine. You can download the latest version from the official website:

Usage

1. Create a queries.sql file

Before running sortQL, you need to create the queries.sql file. In this file, we're going to specify a set of operations to be executed.

You can create it anywhere you like: in a project directory, in a subfolder, or even on your desktop.

Here's and example of a queries.sql file:

-- Example: Selecting all folders and files from the directory
SELECT 'files' FROM ''

2. Run sortQL

Now that you have the queries.sql file, you can run sortQL from the terminal. Simply run the following command:

npx @sortql/sortql-cli@latest

3. Where do you want to run the queries?

Upon start, you will be prompted to enter a directory where you want to run the queries. This can be any directory on your computer, such as your desktop, documents folder, or a subfolder within a project directory.

? Where do you want to run the queries? '/Users/username/Desktop/messy-folder'

4. Where is your queries.sql file located?

Next, you will specify a path to the queries.sql file. Simply enter the full path to the file, or drag and drop the file into the terminal.

? Where is your queries.sql file located? '/Users/username/Desktop/queries.sql'

5. Want to watch for changes?

Addtionally, you can specify if you want to watch for changes. This will automatically re-run the queries whenever a file or folder is added, removed, or modified.

? Do you want to watch the directory for changes and rerun queries? (y/n) 'y'

[!NOTE] Once you press enter, sortQL will save your configuration in ~/.sortql. This will allow you to run sortQL without having to specify the path to the queries.sql file and the directory every time you run it. To change the configuration, simply run npx @sortql/sortql-cli@latest --config.

After saving the configuration, sortQL will start running the queries and display the results in the terminal.

You're all set!

That's it. Feel free to play around with the queries.sql file and see how sortQL behaves. In case you need to stop the process, simply enter CTRL + C in the terminal.

Documentation

For more information on how to use sortQL, please refer to the documentation.

Troubleshooting

If you encounter any issues while using sortQL, please create an issue here.

Contributing

To contribute to this project, please take a look at the contributing guidelines.

License

sortQL is open-source software licensed under the MIT License. See the License file for more information.