RandomTroll

Untitled

Aug 18th, 2026 (edited)
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.88 KB | Source Code | 0 0
  1. #! /bin/bash
  2.  
  3. # echo "This script removes metacharacters, including spaces, from all file names in the current directory, and converts diacritically-marked characters to ASCII"
  4.  
  5. for file in *
  6. do
  7.     NewName=`echo $file | tr -d '[]{}&#,() ;?\"|@' | tr -d \' | sed 's/á/a/g;s/à/a/g;s/ä/a/g;s/â/a/g;s/å/a/g;s/ã/a/g;s/é/e/g;s/è/e/g;s/ë/e/g;s/ê/e/g;s/í/i/g;s/ì/i/g;s/ï/i/g;s/î/i/g;s/ó/o/g;s/ò/o/g;s/ö/o/g;s/ô/o/g;s/õ/o/g;s/ø/o/g;s/ú/u/g;s/ù/u/g;s/ü/u/g;s/û/u/g;s/æ/ae/g;s/ñ/n/g;s/ÿ/y/g;s/ç/c/g;s/ß/ss/g;s/Á/A/g;s/À/A/g;s/Ä/A/g;s/Â/A/g;s/Å/A/g;s/Ã/A/g;s/É/E/g;s/È/E/g;s/Ë/E/g;s/Ê/E/g;s/Í/I/g;s/Ì/I/g;s/Ï/I/g;s/Î/I/g;s/Ó/O/g;s/Ò/O/g;s/Ö/O/g;s/Ô/O/g;s/Õ/O/g;s/Ø/O/g;s/Ú/U/g;s/Ù/U/g;s/Ü/U/g;s/Û/U/g;s/Æ/AE/g;s/Ñ/N/g;s/œ/oe/g;s/Œ/OE/g'`
  8.     if [ "$file" != $NewName ]
  9.     then   
  10.         mv -n "$file" $NewName
  11.         echo renamed $file to $NewName
  12.     fi 
  13. done
  14.  
Advertisement
Add Comment
Please, Sign In to add comment