@sortql/sortql-cli

1.3.1 • Public • Published

angular-logo
A file management automation tool with SQL-like syntax.

Quick Start · Documentation · Submit an Issue

NPM Version NPM Downloads NPM License NPM License GitHub Actions Workflow Status GitHub Repo stars

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.

Package Sidebar

Install

npm i @sortql/sortql-cli

Weekly Downloads

0

Version

1.3.1

License

MIT

Unpacked Size

1.55 MB

Total Files

4

Last publish

Collaborators

  • leonmeka