-
-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
310a310
commit e694e75
Showing
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
# Function to rename files by removing the numeric prefix | ||
rename_files() { | ||
for file in "$1"/*; do | ||
if [ -d "$file" ]; then | ||
# If the file is a directory, recursively call the function | ||
rename_files "$file" | ||
elif [ -f "$file" ]; then | ||
# Check if the file has a prefix number followed by a hyphen or space | ||
if [[ $(basename "$file") =~ ^[0-9]+[-\ ] ]]; then | ||
# Remove the prefix and rename the file | ||
new_name=$(echo "$(basename "$file")" | sed -E 's/^[0-9]+[-\ ]//') | ||
mv "$file" "$(dirname "$file")/$new_name" | ||
fi | ||
fi | ||
done | ||
} | ||
|
||
# Run the function starting from the current directory | ||
rename_files "$(pwd)" | ||
|
||
echo "Renaming completed!" |