/open-file-manager-dialog

Cross-platform library for opening a file manager dialog window programmatically on MacOS, Windows, or Linux.

Primary LanguageJavaScriptMIT LicenseMIT

open-file-manager-dialog NPM version NPM monthly downloads NPM total downloads

Cross-platform library for opening a file manager dialog window programmatically on MacOS, Windows, or Linux.

Please consider following this project's author, Jon Schlinkert, and consider starring the project to show your ❤️ and support.

Install

Install with npm:

$ npm install --save open-file-manager-dialog

Usage

import { openFileManagerDialog, parsePaths } from 'open-file-manager-dialog';
// or
import openFileManagerDialog from 'open-file-manager-dialog';

API

Signature:

export const openFileManagerDialog = async (
  dirname?: string,
  options?: { multiple?: boolean; filter?: string; }
): Promise<string[]>;

This library is powered by open-finder-dialog, open-linux-file-dialog, and open-windows-file-dialog. See their documentation for more details and to learn about available options.

Usage

// Open the dialog in the current working directory
const selectedPaths = await openFileManagerDialog();
console.log('Selected paths:', selectedPaths);

Opens the native file manager dialog for the current OS (Windows, macOS, or Linux) to select files or directories. Returns the paths of selected files as an array of strings.

Params

dirname (optional)

The initial directory or file path where the dialog should open. Defaults to the current working directory.

const selectedPaths = await openFileManagerDialog('/some/folder');

options (optional)

  • multiple (boolean): Allow selection of multiple files (default: false).
  • filter (string): Filter file types, for example "*.jpg".
// Allow selecting multiple PDF files from a directory
const { files, canceled } = await openFileManagerDialog('/some/folder', {
  multiple: true,
  filter: ['pdf']
});

Related

You might also be interested in:

About

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Running Tests

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

$ npm install && npm test
Building docs

(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)

To generate the readme, run the following command:

$ npm install -g verbose/verb#dev verb-generate-readme && verb

Author

Jon Schlinkert

License

Copyright © 2025, Jon Schlinkert. Released under the MIT License.


This file was generated by verb-generate-readme, v0.8.0, on May 25, 2025.