Handy One-Liners

Renaming multiple files

    for i in *.jpg.png; do mv $i ${i/.jpg}; done   #deletes the .jpg from the middle of the name

    for i in {1..9}; do mv training${i}.jpg training0${i}.jpg;done    # renames training1.jpg to training01.jpg

Keeping left justified or leading zeros

# Add 1 to all the file numbers but keep the leading zeros
# title00.mkv --> Show_S03E01.mkv
# title01.mkv --> Show_S03E02.mkv

for X in {00..10}; do Y=`printf "%02d" $((10#$X + 1))`;echo mv "title$X.mkv" "Show_S03E$Y.mkv";done

Comments