Skip to content

Simple node.js command line tool to rename files written in Typescript

Notifications You must be signed in to change notification settings

siuangie91/batch-renamer

Repository files navigation

Batch-renamer

Simple node.js tool to batch rename files from one folder to another with a specified prefix.

Usage

  1. Clone this repo.
  2. Install the app.
    cd path/to/batch-renamer
    nvm use && yarn
  3. Run the app with the arguments:
    yarn batch-rename -o <absolute path to origin folder> -p <desired prefix>

Run yarn batch-rename --help to see arguments/options.

Arguments

Argument Alias Description Example Required?
--origin -o Absolute path to original folder of files to rename /Users/userName/Desktop/originalFolder Yes
--prefix -p Prefix for the renamed files new-name Yes
--target -t Absolute path to folder to save renamed files to. Creates the folder if it doesn't already exist.

ℹ️ If not provided, a new folder called {originalFolder}_renamed will be created.
/Users/userName/Desktop/renameToHere No
--startingIndex -s Custom starting index for renamed files.
If not provided, file numbers will start at 001.

ℹ️ Note that file numbers will have at least 3 digits (leading zeroes are added as necessary).
13 No

Example

Without starting index

Given this folder on your desktop:

original
  |_file.jpg
  |_image.png

whose absolute path is ~/Desktop/original, rename all the files in there with prefix of Renamed:

yarn batch-rename -o ~/Desktop/original -p Renamed

Results in:

original # origin folder
  |_file.jpg
  |_image.png

original_renamed # new folder, created if not already existing
  |_Renamed-001.jpg
  |_Renamed-002.png

With starting index

Using that same folder, rename all of the files with starting index of 300:

yarn batch-rename -o ~/Desktop/original -p Renamed -s 300

Results in:

original # origin folder
  |_file.jpg
  |_image.png

original_renamed # new folder, created if not already existing
  |_Renamed-300.jpg
  |_Renamed-301.png

Useful when used with --target.

With specified target folder

Target folder already exists

Given this folder structure on your desktop:

original # contains file to rename
  |_file.jpg
  |_image.png

other # will contain renamed files
  |_Prefix-301.js

Rename all of the files in original with starting index of 302, prefix of Prefix and store in the other folder:

yarn batch-rename -o ~/Desktop/original -p Prefix -t ~/Desktop/other -s 302

Results in:

original # origin folder
  |_file.jpg
  |_image.png

other # now also contains renamed files from original
  |_Prefix-301.js
  |_Prefix-302.jpg
  |_Prefix-303.png

This is useful for when you already have files in the target folder with the given prefix.

Target folder does not yet exist

Given this folder on your desktop:

original # contains file to rename
  |_file.jpg
  |_image.png

Rename all of the files in original and store in a new copy folder in the ~/Desktop/subfolder/ directory with a prefix of Copied:

yarn batch-rename -o ~/Desktop/original -p Copied -t ~/Desktop/subfolder/copy

Results in:

Desktop
  |_original # origin folder
    |_file.jpg
    |_image.png
  |_subfolder
    |_copy # created new folder that did not exist before
      |_Copied-001.js
      |_Copied-002.jpg

This is useful for when you know exactly where you want the target folder to go.

About

Simple node.js command line tool to rename files written in Typescript

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published