TheAlgorithms / scripts

Scripts used across all The Algorithms repositories
MIT License
77 stars 43 forks source link

[FEATURE] Add a filename formatter script #4

Closed Panquesito7 closed 1 year ago

Panquesito7 commented 2 years ago

Description

There's a filename formatter that's being used already in various repositories, such as the TypeScript repository repository, the C/C++ repositories, and soon other repositories as well.

This is not a Python script but more of a Bash script, I guess. What do you think? Should we adjust it and add it to this repository? Thanks.

          IFS=$'\n'
          for fname in `find . -type f -name '*.cpp' -o -name '*.hpp'`
          do
            echo "${fname}"
            new_fname=`echo ${fname} | tr ' ' '_'`
            echo "      ${new_fname}"
            new_fname=`echo ${new_fname} | tr 'A-Z' 'a-z'`
            echo "      ${new_fname}"
            new_fname=`echo ${new_fname} | tr '-' '_'`
            echo "      ${new_fname}"
            if [ ${fname} != ${new_fname} ]
            then
              echo "      ${fname} --> ${new_fname}"
              git "mv" "${fname}" ${new_fname}
            fi
          done

CC: @raklaptudirm, @appgurueu, you might want to check this out as well.

appgurueu commented 2 years ago

Sure, why not