Shell one liner to pad filenames starting with single digit year with a zero
Pad filenames starting with a single digit year (e.g. 1, 2, etc) with a zero while leaving filesnames starting with two digit years (e.g. 11, 12) untouched.
$ ls -1 10th.Circuit 11th.Circuit 1st.Circuit 2nd.Circuit 3rd.Circuit 4th.Circuit 5th.Circuit 6th.Circuit 7th.Circuit 8th.Circuit 9th.Circuit DC.Circuit
$ for old in $(ls -1 | grep "^[0-9]\{1\}[a-z]"); do rename -n 's//0/' $old; done 1st.Circuit renamed as 01st.Circuit 2nd.Circuit renamed as 02nd.Circuit 3rd.Circuit renamed as 03rd.Circuit 4th.Circuit renamed as 04th.Circuit 5th.Circuit renamed as 05th.Circuit 6th.Circuit renamed as 06th.Circuit 7th.Circuit renamed as 07th.Circuit 8th.Circuit renamed as 08th.Circuit 9th.Circuit renamed as 09th.Circuit
Leave a comment