spacesjs

1.4.3 • Public • Published

SpacesJS

This is a little Node.js program for renaming files in the current working directory. It replaces spaces with hyphens and converts all uppercase characters to lowercase ones.

Technically, the regular expression selects all whitespace (spaces, tabs, linefeeds, and carriage returns) and hyphens in any order. These groups of characters will be replaced with a SINGLE hyphen, and then JavaScript converts all uppercase characters to lowercase ones. This RegEx pattern accounts for the use-case in which a hyphen precedes or follows a space, for example feminism -lol.png. A previous iteration of this program did not account for this scenario, so it could potentially produce filenames such as feminism--lol.png which is not horrible, but it is certainly more cumbersome than a file that doesn't contain consecutive hyphens.

Instructions

Install node. After this, install SpacesJS:

npm install -g spacesjs

Then, simply run the command spacesjs in the target directory.

Future Additions:

  • error handling and unique messages (no files renamed, # of files renamed, etc.)
  • the ability to anticipate duplicate filenames
  • the elimination of additional (potentially detrimental) special characters
  • the elimination of hyphens just before the extension (image-.png)
  • prevent file extensions from being modified

Thanks to Tim Spinks for making valuable RegEx suggestions.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.4.3
    5
    • latest

Version History

Package Sidebar

Install

npm i spacesjs

Weekly Downloads

98

Version

1.4.3

License

ISC

Unpacked Size

2.57 kB

Total Files

3

Last publish

Collaborators

  • jeffreysbrother