rename_safe/test_rename.sh
2025-07-20 19:46:33 +00:00

47 lines
No EOL
1.1 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
set -e
# Create test directory
TEST_DIR="test_dir"
rm -rf "$TEST_DIR"
mkdir -p "$TEST_DIR"
cd "$TEST_DIR"
# Create test files with edge cases
touch "Test File (1).txt"
touch "Test File (2).txt"
touch "60% of Americans Dont Have $1000 to Pay For Unexpected Medical Expenses.en.vtt"
touch "Are You The Patsy.en.vtt"
touch "Can You Change The Culture of Healthcare At your Company.en.vtt"
touch "Lets Play A Game!.en.vtt"
touch "Spend More Time Researching Your Healthcare Budget!.en.vtt"
touch "401(k) Plan.en.vtt"
touch "Duplicate Name"
touch "Duplicate Name"
touch "Hidden File"
mv "Hidden File" ".Hidden File" # Make it a hidden file
# Create a long filename that is under the system limit (255 chars max)
long_base="VeryLongFilename_$(printf 'A%.0s' {1..234})"
touch "$long_base.txt"
# Print original files
echo "🔍 Original files:"
ls -1
# Dry run test
echo -e "\n🧪 Dry run (--dry-run):"
../rename_safe.sh --dry-run .
# Actual run test
echo -e "\n🚀 Actual run:"
../rename_safe.sh .
# Final listing
echo -e "\n✅ Final files after renaming:"
ls -1
# Cleanup
cd ..
rm -rf "$TEST_DIR"