https://github.com/buonzz/filestosql
Recursively Crawl files in a folder and generate SQL script to easily load the file list to a MySQL database
https://github.com/buonzz/filestosql
cms discovery filesystem tools
Last synced: 5 months ago
JSON representation
Recursively Crawl files in a folder and generate SQL script to easily load the file list to a MySQL database
- Host: GitHub
- URL: https://github.com/buonzz/filestosql
- Owner: buonzz
- Created: 2019-02-23T14:56:17.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-02-24T13:45:08.000Z (over 7 years ago)
- Last Synced: 2025-10-21T16:56:40.135Z (8 months ago)
- Topics: cms, discovery, filesystem, tools
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/filestosql
- Size: 8.79 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Files to SQL
A ClI (command line interface) tool to get a listing of all files inside a folder (and its subfolders) and generate a SQL file so you can easily analyze it using standard SQL queries.
### Usage
Go to the folder which you want to generate the sql and then execute:
```
npx filestosql
```
it will then generate a .sql in the current directory.
You can also specify the target folder and output file via command line arguments
```
npx filestosql --folder=/path/to/folder/to/crawl --output=path/to/sql/file.sql
```
You can also install it globally if you need to use it repetitively
```
npm install -g filestosql
```
### Using the generated SQL file
the entire purpose of the sql file is so that you can load that into your MySQL database. You can then query the database for your reporting needs.
for example:
```
mysql -u user -p dbname -h localhost < path/to/sql/file.sql
```
make sure you have the following schema in your mysql database
```
CREATE TABLE IF NOT EXISTS files (
id INT AUTO_INCREMENT,
filename VARCHAR(255) NOT NULL,
filepath VARCHAR(500) NOT NULL,
dirname VARCHAR(255) NOT NULL,
extension VARCHAR(255) NOT NULL,
content_hash VARCHAR(255) DEFAULT NULL,
content_size VARCHAR(255) DEFAULT NULL,
file_type VARCHAR(50) DEFAULT NULL,
tags TEXT DEFAULT NULL,
last_indexed BIGINT DEFAULT NULL,
UNIQUE KEY unique_filepath (filepath),
PRIMARY KEY (id)
) ENGINE=INNODB;
```