Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mefengl/awsome-shell
some shell script to use and learn from it
https://github.com/mefengl/awsome-shell
Last synced: 10 days ago
JSON representation
some shell script to use and learn from it
- Host: GitHub
- URL: https://github.com/mefengl/awsome-shell
- Owner: mefengl
- License: mit
- Created: 2022-12-05T10:24:18.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2022-12-05T10:26:47.000Z (about 2 years ago)
- Last Synced: 2024-10-30T10:15:31.986Z (about 2 months ago)
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Awsome-Shell
some shell script to use and learn from it## -h example
```bash
#!/bin/bash# Display usage information and examples
display_help() {
echo "Usage: $0 fromExt toExt"
echo
echo "Renames all files with the specified fromExt extension to have the specified toExt extension"
echo
echo "Examples:"
echo " $0 \".ts\" \".cs\" # Renames all .ts files to .cs files"
echo " $0 \".js\" \".ts\" # Renames all .js files to .ts files"
echo " $0 \".txt\" \".md\" # Renames all .txt files to .md files"
}# Check if the correct number of arguments was provided
if [ "$#" -ne 2 ]; then
echo "Error: Invalid number of arguments" >&2
display_help
exit 1
fi# Check if the -h or --help option was provided
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
display_help
exit 0
fi
```## batch_rename
```bash
# Assign the arguments to variables
fromExt=$1
toExt=$2# Rename the files
for file in *"$fromExt"; do mv "$file" "${file%$fromExt}$toExt"; done
```