Skip to content

Instantly share code, notes, and snippets.

@coskuntekin
Created April 19, 2023 02:57
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 coskuntekin/21f4caa183c3fe9475df7babcd14a953 to your computer and use it in GitHub Desktop.
Save coskuntekin/21f4caa183c3fe9475df7babcd14a953 to your computer and use it in GitHub Desktop.
Rename file name to lowercase and add underscore for the spaces in the folder
#!/bin/bash
for file in *.png; do
new_file=$(echo "$file" | tr '[:upper:]' '[:lower:]' | sed 's/ /_/g')
mv "$file" "$new_file"
done
@coskuntekin
Copy link
Author

coskuntekin commented Apr 25, 2023

for file in *.PNG; do
    newname=$(echo $file | sed -r 's/([a-z0-9])([A-Z])/\1-\L\2/g' | tr '[:upper:]' '[:lower:]')
    mv "$file" "$newname"
done```

In the folder rename PNG files. Rename Uppercase to lowercase and if it's CamelCase add dash between words

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment