This guide explains how to test the mass_rename.sh script, which efficiently renames groups of files. It utilizes dummy files to allow for safe testing of the renaming process.
- mass_rename.sh: Used to rename groups of files based on your input. This is the main script that automates the renaming process.
- DummyFileCreater.sh: A script to create a
test-dirdirectory containing empty dummy files for safely testing the renaming process. - DummyList.txt: A list of filenames used by
DummyFileCreater.shto populate thetest-dirdirectory.
To run the script, you will need:
- The BASH shell installed.
sedinstalled for text processing.
To test the renaming process safely, you’ll need some sample files. The DummyFileCreater.sh script will create a directory called test-dir, and generate dummy files within it.
Run the following command to create the dummy files:
./DummyFileCreater.shNote
If you encounter a permissions error, the script might not be executable. You can bypass this by running:
bash ./DummyFileCreater.shOnce the dummy files are created, run the mass_rename.sh script to begin the renaming process:
./mass_rename.shThe script will prompt you for the directory containing the files. Since you created test-dir in Step 1, enter that directory name:
Where are the files located?: test-dirThe script will then display the list of files found in test-dir, for example:
These are the files located : test-dir
[fan] name of file (date).720p.mhsie.mkv
[fan] name of file (date)E01S01.720p.mhsie.mkv
[lovesubs].anime_name.E01S01.[1080p].epname.stuff.mkv
...
WordGirl - 1x01 - Tobey or Consequences High Fat Robbery.mp4
WordGirl - 1x02 - You Cant Crush City Hall Two Brain Highway.mp4
...The script will now check for filenames in the selected directory for the presence of brackets [] or parentheses (). If any such files are present, their names be shown, and you'll be asked if you want to remove these characters. This check is skipped if no matching filenames are found.
For example:
The following files contain brackets or parentheses:
[fan] name of file (date).720p.mhsie.mkv
[lovesubs].anime_name.E01S01.[1080p].epname.stuff.mkv
Do you want to remove the brackets and parentheses? (yes/no):Warning
If you select yes, all instances of brackets [] will be removed in this step. These brackets can be added back in the immediately following step if desired.
- Type
yesoryto automatically remove the brackets or parentheses. - Type
noornto keep them unchanged.
You are now prompted to specify the portion of the filenames you wish to change. For example, to replace WordGirl - 1x, input this:
WordGirl - 1xTip
You can also cut and paste the text directly from the file list above.
After specifying the text to change, the screen will refreash, displaying the files that will be affected.
Please input what you want to changed: WordGirl - 1x
WordGirl - 1x01 - Tobey or Consequences High Fat Robbery.mp4
WordGirl - 1x02 - You Cant Crush City Hall Two Brain Highway.mp4
WordGirl - 1x03 - Coupon Madness When Life Gives You Potatoes.mp4
...
Please input what you want to add: The prompt asks for the text you want to add. For example, to change the series' numbering format, type:
S01ENote
If you leave the input blank, the specified text (e.g., WordGirl - 1x) will be removed without replacement.
The script will now display the proposed changes for your review:
Proposed changes for renaming:
WordGirl S01E01 - Tobey or Consequences High Fat Robbery.mp4
WordGirl S01E02 - You Cant Crush City Hall Two Brain Highway.mp4
WordGirl S01E03 - Coupon Madness When Life Gives You Potatoes.mp4
WordGirl S01E04 - Jerky Jerk Becky's Birthday.mp4
...
No changes have been made.
You will then be asked to confirm these changes:
Do you accept these changes? (yes/no):- Type
yesoryto apply the changes. - Type
noornto reject the changes. Return to step 5
This prompt asks if you need to make any further changes to the files in the current directory.
Do you want to change anything else in this directory? (yes/no):- Type
yesoryreturn to Step 4 for additional changes. - Type
noornto exit the program.
- Running
DummyFileCreater.shagain will reset thetest-dirdirectory, allowing you to create fresh dummy files for further testing. - To customize your test cases, simply edit the
DummyList.txtfile and add more filenames. The next time you runDummyFileCreater.sh, the additional filenames will be created in thetest-dirdirectory.
Feel free to provide feedback, suggest improvements, or report any issues!