Skip to content

Instantly share code, notes, and snippets.

@chaicko
Created November 6, 2017 23:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chaicko/38ab786282255707581e35833bf90521 to your computer and use it in GitHub Desktop.
Save chaicko/38ab786282255707581e35833bf90521 to your computer and use it in GitHub Desktop.
Bash recipes
#!/bin/bash
# Rename a bunch of files by removing the last 2 characters of the filename (not the extension)
for f in *.*; do fname=${f%.*}; extension=${f##*.}; mv $f ${fname%??}.${extension}; done
# How? use bash substituions http://www.tldp.org/LDP/abs/html/parameter-substitution.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment