A node.js-based command-line interface (CLI) tool to predict the types of files using Magika.
Before using the CLI, make sure you have Node.js installed on your machine.
-
Clone this repository:
git clone <repository-url>
-
Navigate to the project directory:
cd predict-files
-
Install dependencies:
npm install
Run the CLI using the following command:
npm run predict -- <files...>
Replace <files...>
with the paths to the files you want to predict.
-p, --pretty
: Pretty print the output.--format <format>
: Output format (json
ortext
). Default format isjson
.
Predict the types of a file:
❯ npm run predict -- files/cat
[
{ file: 'files/cat', prediction: { label: 'gif', score: 1 } }
]
Predict the types of multiple files and pretty print the output:
❯ npm run predict -- -p files/table files/zippedcat
[
{
"file": "files/table",
"prediction": {
"label": "csv",
"score": 0.9918680787086487
}
},
{
"file": "files/zippedcat",
"prediction": {
"label": "zip",
"score": 0.9999768733978271
}
}
]
Predict the types of all files in a folder and output in text format:
❯ npm run predict -- --format text files/*
File: files/cat
Label: gif
Score: 1
---
File: files/demo
Label: txt
Score: 1
---
File: files/table
Label: csv
Score: 0.9918680787086487
---
File: files/zippedcat
Label: zip
Score: 0.9999768733978271
This project is licensed under the MIT License.