I wanted to write a program to index my library of media using a Mongo database and I needed to be able to gather all my files and put them with their full path into the database so I wrote a script to do that for me :smiley-face:
- clone this repo
npm install
sudo chmod u+x index.js
or use withnode
instead./index.js -t [movie|rom] -f [starting folder] >> file.json
to write out to a file- done, import data like a boss
I wrote this for use with a file structure that Plex uses, specifically for Movies. Click here to learn more about the kind of file structure im talking about.
Expected output: {"name": 'The Room', path: "/user/path/to/The Room", "filesize": "1kb"}
The script (when -t movie
is run) will OMIT folders named Featurettes
and Subs
, as well as files ending with .sfv
and .srt
because I dont really want those in my database.
Like for getting movie names, running -t rom
searches a directory for files but grabs more relevant information like filesize and category of rom.
The script will assume your folder structure is something like:
/
/SNES
rom
/NES
rom
/Neogeo
/BIOS
bios
rom
rom
...etc
Expected output: {"category": "SNES", "name": "rom", "filesize": "1kb"}
If there are subdirectory, the category for those files in the subdirectory will be the name of that subdir: {"category": "BIOS", "name": "bios", "filesize": "1kb"}
This one just walks through a given folder and its subfolders and adds all files
Expected output: {"name" "file.jpg", "path": "/my/images/file.jpg", "filesize": "2kb"}
i would like to add support for adding custom object templates for output
if there is something missing just clone and add it urself :)