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 🙏

© 2025 – Pkg Stats / Ryan Hefner

photo-cli

v1.0.0

Published

A cli for importing and managing photos.

Readme

Photo CLI

A command line tool for organizing photo and video files using glob patterns and path templates.

Installation

Make sure NodeJS and npm is installed and run:

npm install -g photo-cli

Usage

Import

The import command copies/moves files from an input directory to an output destination. The input/output paths of each file are determined using a mustache template:

my-tempalte:
  - from: "{{input}}/*.jpg"
    to: "{{output}}/Pictures/{{filename}}"

A template consists of an array of from/to pairs where the rendered from string is used as a glob pattern to find input files and the rendered to string is used as the output path.

Each file is analyzed using ExifTool to extract image/video metadata. The extracted metadata is passed along when rendering the path template allowing you to use the metadata for the output path:

my-tempalte:
  - from: "{{input}}/*.jpg"
    to: "{{output}}/Pictures/{{year}}-{{month}}-{{day}}/{{filename}}"

In the example above the extracted date information is used for the name of the output directory.

List of available template properties

from tempalte properties

| Name | Description | | --------- | --------------------------------------------------------------------------- | | input | The input path provided using the preset or the --input flag. | | output | The output path provided using the preset or the --output flag. | | project | The project name provided using the --project flag. | | ext | Object containing different glob patterns for common media file extensions. |

Extensions

The from template receives glob patterns for common media file extensions in the ext object: ext.images, ext.raws, ext.allImages, ext.video, ext.allMedia. See `src/lib/template.ts for more info. You can also provide your own glob pattern:

// Get all .png files
*.png

// Get .png and .PNG files
*.{png,PNG}

to template properties

You can run the import command with the --verbose flag to see the template properties that are used for each file:

photo import --input . --template my-template --verbose

Here is an overview of the available properties: | Name | Description | | ---------- | -------------------------------------------------------------------------------------------------------------------------------- | | exif | Object containing the extracted exif metadata. You can access the properties using javascript dot notation e.g. exif.FileName. | | filename | The name of the file with extension. Same as exif.FileName. | | dirname | Base name of the parent directory of the file (not the full path) |

Dates

For each file the CreateDate property from the exif metadata is parsed and provided to the template with the following properties: year, month, day, hour, minute, second. Additionally, you can use custom formatting using the function syntax of mustache:

{{# date}}yyyy-MM-dd{{/ date}}

The string between the date tags will be formated using date-fns.

In addition to date, two more dates will be passed along: f_date (first date) and l_date (last date) (as well as f_year/l_year, etc.). They are the dates of the earliest/latest image/video being imported and can be used to group files taken over a longer period of time.

Template and preset configuration

The import command relies on presets and templates that are defined in the photo-cli config file. You can edit the file by running photo config and opening the file in your favorite text editor.

The config file is a yaml file with the following format:

presets:
  <name>:
    input: <input path> 
    output: <output path> 
    template: <tempalte name> 
templates:
  <name>:
    - from: <from template> 
      to: <to template> 

Templates are configured as described above. Presets can be used to provide default values for import command flags --input, --output, and --template.

Example config

presets:
  canon:
    input: F:/DCIM/100CANON
    output: M:/Pictures
    template: date 
templates:
  date:
    - from: "{{input}}/{{ext.allMedia}}"
      to: "{{output}}/{{year}}-{{month}}-{{day}}/{{filename}}"

The above config contains a preset for importing files from an SD card used in a Canon camera to a pictures directory using a date preset that organizes files in directories by date. Files can be imported using this preset with the following command:

photo import canon

Commands

photo config

Edit the photo-cli config.

USAGE
  $ photo config

DESCRIPTION
  Edit the photo-cli config.

See code: dist/commands/config.ts

photo help [COMMAND]

Display help for photo.

USAGE
  $ photo help [COMMAND] [-n]

ARGUMENTS
  COMMAND  Command to show help for.

FLAGS
  -n, --nested-commands  Include all nested commands in the output.

DESCRIPTION
  Display help for photo.

See code: @oclif/plugin-help

photo import [PRESET]

Imports files from the input directory to the output directory using a path template.

USAGE
  $ photo import [PRESET] [-i <value>] [-o <value>] [-t <value>] [-P <value>] [-p <value>] [-c] [-m] [-f]
    [-v]

FLAGS
  -P, --preset=<value>    name of the import preset
  -c, --confirm           performs the import without additional user confirmation
  -f, --force             overwrite existing files in output directory
  -i, --input=<value>     input path
  -m, --move              move files instead of copy
  -o, --output=<value>    output path
  -p, --project=<value>   the project name of the import
  -t, --template=<value>  name of the template config
  -v, --verbose

DESCRIPTION
  Imports files from the input directory to the output directory using a path template.

EXAMPLES
  $ photo import

See code: dist/commands/import.ts

photo config

Edit the photo-cli config.

USAGE
  $ photo config

DESCRIPTION
  Edit the photo-cli config.

See code: dist/commands/config.ts

photo help [COMMAND]

Display help for photo.

USAGE
  $ photo help [COMMAND] [-n]

ARGUMENTS
  COMMAND  Command to show help for.

FLAGS
  -n, --nested-commands  Include all nested commands in the output.

DESCRIPTION
  Display help for photo.

See code: @oclif/plugin-help

photo import [PRESET]

Imports files from the input directory to the output directory using a path template.

USAGE
  $ photo import [PRESET] [-i <value>] [-o <value>] [-t <value>] [-P <value>] [-p <value>] [-c] [-m] [-f]
    [-v]

FLAGS
  -P, --preset=<value>    name of the import preset
  -c, --confirm           performs the import without additional user confirmation
  -f, --force             overwrite existing files in output directory
  -i, --input=<value>     input path
  -m, --move              move files instead of copy
  -o, --output=<value>    output path
  -p, --project=<value>   the project name of the import
  -t, --template=<value>  name of the template config
  -v, --verbose

DESCRIPTION
  Imports files from the input directory to the output directory using a path template.

EXAMPLES
  $ photo import

See code: dist/commands/import.ts