Skip to content

Instantly share code, notes, and snippets.

@sagax
Last active January 28, 2018 01:13
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 sagax/19e5e61509905632244a89c7b3c2095f to your computer and use it in GitHub Desktop.
Save sagax/19e5e61509905632244a89c7b3c2095f to your computer and use it in GitHub Desktop.
to rename strange file name
ls | awk '/\.webm$/{original=$0; split($0, s, ""); line=""; for(i in s){ if (s[i] ~ /([a-zA-Z0-9]|\s|\.|-)/) {line=line s[i]; }}; split(line, nline, "-"); oleft=nline[1]; left=nline[1]; right=nline[2]; left=tolower(left); sub(/^\s+/, "", left); sub(/(^\s+|\s+$)/, "", left); print original " >> " left"-"right }'
# example
# ► 1 HOUR CHILLSTEP MIX JANUARY 2015 ◄ ~( ̄▽ ̄)~-_0kAYDIyIyo.webm >> 1 hour chillstep mix january 2015-0kAYDIyIyo.webm
# ► 1 HOUR MELODIC DUBSTEP MIX JANUARY 2015 ◄ ~( ̄▽ ̄~)-Cd9hekSTYAE.webm >> 1 hour melodic dubstep mix january 2015-Cd9hekSTYAE.webm
# ► BEST OF CHIPTUNE MIX FEBRUARY 2015 ◄ ~( ̄▽ ̄)~-Ik7VvFDs9pw.webm >> best of chiptune mix february 2015-Ik7VvFDs9pw.webm
# ► BEST OF GLITCH HOP JANUARY 2015 ◄ (~ ̄▽ ̄)~-vu7YJGiiZX4.webm >> best of glitch hop january 2015-vu7YJGiiZX4.webm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment