Last active
August 29, 2015 14:15
-
-
Save chibby0ne/81507a2821f4b772ff48 to your computer and use it in GitHub Desktop.
One-liner that adds a 0 to filename's ranging from 1 to 9, when there are more than 9 files with numbers appended in their filename, thus fixing the ordering when listed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Add this one-liner script to the PATH variable and have the power to count the files in a directory from anywhere in the command line | |
#NAME is the prefix that the files share in common | |
NAME=$1; ls -1 | grep -E ${NAME}[0-9]{1}\\. | sed -e 'p;s/\([0-9]\)/0\1/g' | xargs -n 2 mv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment