fork download
  1. #!/usr/bin/env bash
  2.  
  3. toDots='\,;:|+@#$%^&*~'
  4. toUnderscores='}{]['"'"'="()`!'
  5.  
  6. runOrDebug() {
  7. if (( debug )); then
  8. printf '%s\n' "${*@Q}"
  9. else
  10. "$@"
  11. fi
  12. }
  13.  
  14. renameFiles() {
  15. local name subDots subBoth
  16.  
  17. for name; do
  18. subDots=${name//["$toDots"]/.}
  19. subBoth=${subDots//["$toUnderscores"]/_}
  20.  
  21. if [[ $subBoth != "$name" ]]; then
  22. runOrDebug mv -- "$name" "$subBoth"
  23. fi
  24. done
  25. }
  26.  
  27. debug=1 renameFiles '[/a],/;[p:r|o\b+lem@a#t$i%c]/@(%$^!/(e^n&t*ry)~='
Success #stdin #stdout 0.01s 5436KB
stdin
Standard input is empty
stdout
'mv' '--' '[/a],/;[p:r|o\b+lem@a#t$i%c]/@(%$^!/(e^n&t*ry)~=' '_/a_./._p.r.o.b.lem.a.t.i.c_/._..._/_e.n.t.ry_._'