Skip to content

A Node.js function which gathers basic details about a local file

License

Notifications You must be signed in to change notification settings

pfbrowning/get-file-details

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

get-file-details

A Node.js function which gathers basic details about a local file synchronously.

Installation

npm i get-file-details --save

Usage

import getFileDetails from 'get-file-details';

const fileDetails = getFileDetails('path/to/your/file');

File Details

This function queries and returns the most basic essential properties for querying and manipulating files. The naming convention used was inspired by this Stackoverflow answer.

export interface FileDetail {
    /** The file name without an extension */
    fileRoot: string;
    /** The file name including its extension */
    fileName: string;
    /** The file extension including the preceeding dot */
    fileExtension: string;
    /** The directory path, excluding the filename */
    directory: string;
    /** The full path to the file, including the directory, filename, and extension */
    absolutePath: string;
    /** The file's size in megabytes */
    fileSizeInMb: number;
    /** The file's size in bytes */
    fileSizeInBytes: number;
    /** The last modified date represented as the number of milliseconds since the Unix Epoch */
    lastModifiedTimestampInMs: number;
    /** The last modified date represented in simplified ISO 8601 format */
    lastModifiedISODateString: string;
}

About

A Node.js function which gathers basic details about a local file

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published