progrez.cloud

RENAME ALL FILES upercase AND flatline WITH BASH

11 Agustus 2020

Tips!



I am use :
  • for, echo, mv, tr, sed


Command:


Get all files by names extension otf, in current location.

While we use *, the key pass value from variabel, and '.otf is limiter' of getter. You can, remove the otf extension. if you most get all files .

for variabel in *.otf


Rename files, (easy understanding).

mv "oldfiles_name" "newfiles_name"


Show text, (easy).

echo "print arguments"


How to lower case the file name ?

tr '[:upper:]' '[:lower:]'


And the last, i m change the char '-' to '_'.

sed s/-/_/g


Finnal code:
#/bin/bash

for filesname in *.otf
mv "$filesname" "$(echo "$filesname" | tr '[:upper:]' '[:lower:]' | sed s/-/_/g)"

Thank you for read my post. If you dont understand my word, in this post. I'm so sorry :'(