Created
November 26, 2014 20:10
-
-
Save tlehman/0d56489acf6ebb3574df to your computer and use it in GitHub Desktop.
pad filenames left with zeros
This file contains hidden or 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
| → ls | |
| file1.txt file14.txt file19.txt file23.txt file28.txt file32.txt file37.txt file41.txt file46.txt file50.txt file55.txt file6.txt | |
| file10.txt file15.txt file2.txt file24.txt file29.txt file33.txt file38.txt file42.txt file47.txt file51.txt file56.txt file7.txt | |
| file11.txt file16.txt file20.txt file25.txt file3.txt file34.txt file39.txt file43.txt file48.txt file52.txt file57.txt file8.txt | |
| file12.txt file17.txt file21.txt file26.txt file30.txt file35.txt file4.txt file44.txt file49.txt file53.txt file58.txt file9.txt | |
| file13.txt file18.txt file22.txt file27.txt file31.txt file36.txt file40.txt file45.txt file5.txt file54.txt file59.txt | |
| ~/tmp/files 2014-11-26 12:09:55 | |
| → for f in $(ls); do newnum=$(ruby -e "/file(?<num>\d+).txt/ =~ '$f'; puts num.rjust(2,'0')"); mv $f file$newnum.txt; done | |
| mv: ‘file10.txt’ and ‘file10.txt’ are the same file | |
| mv: ‘file11.txt’ and ‘file11.txt’ are the same file | |
| mv: ‘file12.txt’ and ‘file12.txt’ are the same file | |
| mv: ‘file13.txt’ and ‘file13.txt’ are the same file | |
| mv: ‘file14.txt’ and ‘file14.txt’ are the same file | |
| mv: ‘file15.txt’ and ‘file15.txt’ are the same file | |
| mv: ‘file16.txt’ and ‘file16.txt’ are the same file | |
| mv: ‘file17.txt’ and ‘file17.txt’ are the same file | |
| mv: ‘file18.txt’ and ‘file18.txt’ are the same file | |
| mv: ‘file19.txt’ and ‘file19.txt’ are the same file | |
| mv: ‘file20.txt’ and ‘file20.txt’ are the same file | |
| mv: ‘file21.txt’ and ‘file21.txt’ are the same file | |
| mv: ‘file22.txt’ and ‘file22.txt’ are the same file | |
| mv: ‘file23.txt’ and ‘file23.txt’ are the same file | |
| mv: ‘file24.txt’ and ‘file24.txt’ are the same file | |
| mv: ‘file25.txt’ and ‘file25.txt’ are the same file | |
| mv: ‘file26.txt’ and ‘file26.txt’ are the same file | |
| mv: ‘file27.txt’ and ‘file27.txt’ are the same file | |
| mv: ‘file28.txt’ and ‘file28.txt’ are the same file | |
| mv: ‘file29.txt’ and ‘file29.txt’ are the same file | |
| mv: ‘file30.txt’ and ‘file30.txt’ are the same file | |
| mv: ‘file31.txt’ and ‘file31.txt’ are the same file | |
| mv: ‘file32.txt’ and ‘file32.txt’ are the same file | |
| mv: ‘file33.txt’ and ‘file33.txt’ are the same file | |
| mv: ‘file34.txt’ and ‘file34.txt’ are the same file | |
| mv: ‘file35.txt’ and ‘file35.txt’ are the same file | |
| mv: ‘file36.txt’ and ‘file36.txt’ are the same file | |
| mv: ‘file37.txt’ and ‘file37.txt’ are the same file | |
| mv: ‘file38.txt’ and ‘file38.txt’ are the same file | |
| mv: ‘file39.txt’ and ‘file39.txt’ are the same file | |
| mv: ‘file40.txt’ and ‘file40.txt’ are the same file | |
| mv: ‘file41.txt’ and ‘file41.txt’ are the same file | |
| mv: ‘file42.txt’ and ‘file42.txt’ are the same file | |
| mv: ‘file43.txt’ and ‘file43.txt’ are the same file | |
| mv: ‘file44.txt’ and ‘file44.txt’ are the same file | |
| mv: ‘file45.txt’ and ‘file45.txt’ are the same file | |
| mv: ‘file46.txt’ and ‘file46.txt’ are the same file | |
| mv: ‘file47.txt’ and ‘file47.txt’ are the same file | |
| mv: ‘file48.txt’ and ‘file48.txt’ are the same file | |
| mv: ‘file49.txt’ and ‘file49.txt’ are the same file | |
| mv: ‘file50.txt’ and ‘file50.txt’ are the same file | |
| mv: ‘file51.txt’ and ‘file51.txt’ are the same file | |
| mv: ‘file52.txt’ and ‘file52.txt’ are the same file | |
| mv: ‘file53.txt’ and ‘file53.txt’ are the same file | |
| mv: ‘file54.txt’ and ‘file54.txt’ are the same file | |
| mv: ‘file55.txt’ and ‘file55.txt’ are the same file | |
| mv: ‘file56.txt’ and ‘file56.txt’ are the same file | |
| mv: ‘file57.txt’ and ‘file57.txt’ are the same file | |
| mv: ‘file58.txt’ and ‘file58.txt’ are the same file | |
| mv: ‘file59.txt’ and ‘file59.txt’ are the same file | |
| ~/tmp/files 2014-11-26 12:10:04 | |
| → ls | |
| file01.txt file06.txt file11.txt file16.txt file21.txt file26.txt file31.txt file36.txt file41.txt file46.txt file51.txt file56.txt | |
| file02.txt file07.txt file12.txt file17.txt file22.txt file27.txt file32.txt file37.txt file42.txt file47.txt file52.txt file57.txt | |
| file03.txt file08.txt file13.txt file18.txt file23.txt file28.txt file33.txt file38.txt file43.txt file48.txt file53.txt file58.txt | |
| file04.txt file09.txt file14.txt file19.txt file24.txt file29.txt file34.txt file39.txt file44.txt file49.txt file54.txt file59.txt | |
| file05.txt file10.txt file15.txt file20.txt file25.txt file30.txt file35.txt file40.txt file45.txt file50.txt file55.txt | |
| ~/tmp/files 2014-11-26 12:10:07 | |
| → |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment