This project includes a script that changes all filenames in a specified directory to either uppercase or lowercase.
The script meets the following requirements:
- The script name is exactly:
/usr/local/bin/case_change
- The script can be in any language as long as it can be executed by running
/usr/local/bin/case_change
- The script accepts the command line option
-c
with possible values ofupper
orlower
The script changes all filenames in the directory /var/tmp/hacker_data/
to uppercase.
The script changes all filenames in the directory /var/tmp/hacker_data/
to lowercase.
Given a filename of TestFile123
, the following will happen:
/usr/local/bin/case_change -c upper # changes the filename to TESTFILE123
/usr/local/bin/case_change -c lower # changes the filename to testfile123
Ensure you have the necessary permissions to add scripts to /usr/local/bin. Save your script as case_change and place it in /usr/local/bin/. Make the script executable:
chmod +x /usr/local/bin/case_change
Run the script using the following syntax: Where can be either upper or lower.
###Example: To change all filenames to uppercase:
/usr/local/bin/case_change -c upper
To change all filenames to lowercase:
/usr/local/bin/case_change -c lower
The script has been improved with the following updates:
Added a check to ensure the script is run with root permissions.
Improved the function names and logic for better readability and maintenance.
Removed redundant cd commands and combined actions within the loop as necessary. Removed unnecessary counters and exit statements inside loops.
Added validation to ensure the correct usage of command-line arguments.
Ensure only files (not directories) are processed.
The script currently operates only on the directory /var/tmp/hacker_data/.
Ensure that the directory exists and contains the files you want to rename before running the script.
License This project is licensed under the MIT License - see the LICENSE file for details.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Feel free to contribute to this project by submitting issues or pull requests. Your feedback and contributions are welcome!