Created
November 19, 2023 09:43
-
-
Save umkl/3a224bd98c39aa73dcd3be751b6a8302 to your computer and use it in GitHub Desktop.
bash_script to remove filename prefixes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Check if the prefix is provided as an argument | |
if [ -z "$1" ]; then | |
echo "Usage: $0 <prefix>" | |
exit 1 | |
fi | |
# Get the prefix from the command line argument | |
prefix="$1" | |
# Rename files by removing the specified prefix | |
for file in "${prefix}"*; do | |
new_name="${file#${prefix}}" | |
mv "$file" "$new_name" | |
echo "Renamed: $file to $new_name" | |
done | |
echo "Script executed successfully!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment