Skip to main content
deleted 1 characters in body
Source Link
Lri
  • 106.4k
  • 19
  • 230
  • 283

for f in "$@"; do new="$(echo -n "$f" | sed -E 's|/$||;s| +$||;s|^ +||;s|/ +([^/]+$)|/\1|;s| +(\.[^.][a-zA-Z0-9.]*)$|.\1|g'$|\1|g')"; mv "$f" "$new"; echo "$new"; done

(Paste as a Run Shell Script action and select Pass input: as arguments.)

for f in "$@"; do new="$(echo -n "$f" | sed -E 's|/$||;s| +$||;s|^ +||;s|/ +([^/]+$)|/\1|;s| +(\.[^.][a-zA-Z0-9.]*)$|.\1|g')"; mv "$f" "$new"; echo "$new"; done

(Paste as a Run Shell Script action and select Pass input: as arguments.)

for f in "$@"; do new="$(echo -n "$f" | sed -E 's|/$||;s| +$||;s|^ +||;s|/ +([^/]+$)|/\1|;s| +(\.[^.][a-zA-Z0-9.]*)$|\1|g')"; mv "$f" "$new"; echo "$new"; done

(Paste as a Run Shell Script action and select Pass input: as arguments.)

added 2 characters in body
Source Link
Lri
  • 106.4k
  • 19
  • 230
  • 283

for f in "$@"; do new="$(echo -n "$f" | sed -E 's|/$||;s| +$||;s|^ +||;s|/ +([^/]+$)|/\1|;s| +\.+(\.[^.][a-zA-Z0-9\9.]*)$|.\1|g')"; mv "$f" "$new"; echo "$new"; done

(Paste as a Run Shell Script action and select Pass input: as arguments.)

for f in "$@"; do new="$(echo "$f" | sed -E 's|/$||;s| +$||;s|^ +||;s|/ +([^/]+$)|/\1|;s| +\.([^.][a-zA-Z0-9\.]*)$|.\1|g')"; mv "$f" "$new"; echo "$new"; done

(Paste as a Run Shell Script action and select Pass input: as arguments.)

for f in "$@"; do new="$(echo -n "$f" | sed -E 's|/$||;s| +$||;s|^ +||;s|/ +([^/]+$)|/\1|;s| +(\.[^.][a-zA-Z0-9.]*)$|.\1|g')"; mv "$f" "$new"; echo "$new"; done

(Paste as a Run Shell Script action and select Pass input: as arguments.)

deleted 194 characters in body
Source Link
Lri
  • 106.4k
  • 19
  • 230
  • 283

Paste as a Run Shell Script action and select Pass input: as arguments:

for f in "$@"; do new="$(echo "$f" | sed -E 's|/$||;s| +$||;s|^ +||;s|/ +([^/]+$)|/\1|;s| +\.([^.][a-zA-Z0-9\.]*)$|.\1|g')"; mv "$f" "$new"; echo "$new"; done

Should work with:

  • somefile .tar.gz
  • EOL + ..plist
  • Terra Nova.S01E05.avi
  • ../ somefile.txt
  • ./somedir /

Doesn't work(Paste as expected with:a Run Shell Script action and select Pass input: as arguments.)

  • Terra Nova .S01E05.avi

Paste as a Run Shell Script action and select Pass input: as arguments:

for f in "$@"; do new="$(echo "$f" | sed -E 's|/$||;s| +$||;s|^ +||;s|/ +([^/]+$)|/\1|;s| +\.([^.][a-zA-Z0-9\.]*)$|.\1|g')"; mv "$f" "$new"; echo "$new"; done

Should work with:

  • somefile .tar.gz
  • EOL + ..plist
  • Terra Nova.S01E05.avi
  • ../ somefile.txt
  • ./somedir /

Doesn't work as expected with:

  • Terra Nova .S01E05.avi

for f in "$@"; do new="$(echo "$f" | sed -E 's|/$||;s| +$||;s|^ +||;s|/ +([^/]+$)|/\1|;s| +\.([^.][a-zA-Z0-9\.]*)$|.\1|g')"; mv "$f" "$new"; echo "$new"; done

(Paste as a Run Shell Script action and select Pass input: as arguments.)

added 288 characters in body
Source Link
Lri
  • 106.4k
  • 19
  • 230
  • 283
Loading
Source Link
Lri
  • 106.4k
  • 19
  • 230
  • 283
Loading