The mvto command is designed to rename specific parts of filenames based on a supplied pattern.
| .gitignore | Remove object file | |
| main.c | Add support for multiple files at once | |
| Makefile | Add support for multiple files at once | |
| README.md | Update README.md | |
Moveto
Description
The mvto command renames a single file by replacing occurrences of a specified pattern with a replacement text.
Functionality
- Matching: It searches for occurrences of the specified pattern within the filename.
- Renaming: Replaces the pattern with the specified replacement text in the filename.
Examples
Example 1:
Rename file1.txt by replacing the part "1.txt" with "2.pdf":
mvto 1.txt 2.pdf file1.txt
Result: Renames file1.txt to file2.pdf.
Example 2:
Rename my-file.txt by replacing "my-" with "your-":
mvto my- your- my-file.txt
Result: Renames my-file.txt to your-file.txt.
Example 3:
Rename photo.jpg by replacing the part ".jpg" with ".png":
mvto .jpg .png photo.jpg
Result: Renames photo.jpg to photo.png.
Example 4:
Rename multiple files a-very-old-old-old-file.txt, old-file.txt, another-older-file.txt by replacing all occurrences of "old" with "new":
mvto old new a-very-old-old-old-file.txt old-file.txt another-older-file.txt
Result: Renames the files to:
new-file.txt
another-newer-file.txt
a-very-new-new-new-file.txt
Installation
Build the executable:
make
Install the command:
sudo make install
Uninstall the command:
sudo make uninstall
Clean up the build files:
make clean
Usage Notes
- The pattern should match exact occurrences within the filename.
- If no occurrences of the pattern are found in the filename, the filename remains unchanged.
- The command operates on filenames in the current directory unless an absolute or relative path is specified.
Author: Amir Teymuri (amtework[at]gmail[dot]com)