Simple node.js tool to batch rename files from one folder to another with a specified prefix.
- Clone this repo.
- Install the app.
cd path/to/batch-renamer nvm use && yarn
- 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.
| 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 |
Given this folder on your desktop:
original
|_file.jpg
|_image.pngwhose absolute path is ~/Desktop/original, rename all the files in there with prefix of Renamed:
yarn batch-rename -o ~/Desktop/original -p RenamedResults in:
original # origin folder
|_file.jpg
|_image.png
original_renamed # new folder, created if not already existing
|_Renamed-001.jpg
|_Renamed-002.pngUsing that same folder, rename all of the files with starting index of 300:
yarn batch-rename -o ~/Desktop/original -p Renamed -s 300Results in:
original # origin folder
|_file.jpg
|_image.png
original_renamed # new folder, created if not already existing
|_Renamed-300.jpg
|_Renamed-301.pngUseful when used with --target.
Given this folder structure on your desktop:
original # contains file to rename
|_file.jpg
|_image.png
other # will contain renamed files
|_Prefix-301.jsRename 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 302Results in:
original # origin folder
|_file.jpg
|_image.png
other # now also contains renamed files from original
|_Prefix-301.js
|_Prefix-302.jpg
|_Prefix-303.pngThis is useful for when you already have files in the target folder with the given prefix.
Given this folder on your desktop:
original # contains file to rename
|_file.jpg
|_image.pngRename 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/copyResults in:
Desktop
|_original # origin folder
|_file.jpg
|_image.png
|_subfolder
|_copy # created new folder that did not exist before
|_Copied-001.js
|_Copied-002.jpgThis is useful for when you know exactly where you want the target folder to go.