21 lines
612 B
Bash
Executable File
21 lines
612 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# Old version:
|
|
# for f in ./*'('*')'*; do mv -i "$f" "${f/ (*)/}"; done
|
|
# for f in ./*/*'('*')'*; do mv -i "$f" "${f/ (*)/}"; done
|
|
|
|
#!/bin/bash
|
|
|
|
# Recursively find all files with parentheses in the name
|
|
find . -type f -name '*(*' -print0 | while IFS= read -r -d '' file; do
|
|
# Extract the new filename without parentheses
|
|
new_name=$(echo "$file" | sed 's/ ([^)]*)//g')
|
|
|
|
# Check if the new name is different from the current name
|
|
if [ "$file" != "$new_name" ]; then
|
|
# Rename the file
|
|
mv -i "$file" "$new_name"
|
|
echo "Renamed: $file to $new_name"
|
|
fi
|
|
done
|