diff --git a/WindowsRenameFix.sh b/WindowsRenameFix.sh deleted file mode 100755 index 80bfb76..0000000 --- a/WindowsRenameFix.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/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 diff --git a/WindowsRnLtFileFix.sh b/WindowsRnLtFileFix.sh deleted file mode 100755 index 2b02981..0000000 --- a/WindowsRnLtFileFix.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/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 date from the parentheses using awk - date_in_parentheses=$(echo "$file" | awk -F'[()]' '{print $2}') - - # Convert the date to a format that can be compared - formatted_date=$(date -d "$date_in_parentheses" +"%Y_%m_%d %H_%M_%S %Z" 2>/dev/null || echo "$date_in_parentheses") - - # Check if the formatted date is valid - if [ -n "$formatted_date" ]; then - # Create a temporary directory for duplicates - temp_dir=$(mktemp -d) - - # Move all files with the same content inside parentheses to the temporary directory - find . -type f -name "*($date_in_parentheses)" -exec mv -i {} "$temp_dir" \; - - # Find the newest file in the temporary directory - newest_file=$(ls -t "$temp_dir" | head -n 1) - - # Move the newest file back to the original location - if [ -n "$newest_file" ]; then - mv -i "$temp_dir/$newest_file" "$file" - echo "Kept: $file and removed older duplicates" - fi - - # Remove the temporary directory - rm -r "$temp_dir" - else - echo "Skipping $file due to invalid date format in parentheses" - fi -done