Pages

Friday, June 13, 2014

Rename with regular expression and leading zeros

$ rename -n 's/result_([0-9]+)_([0-9]+)_([0-9]+)\.json\.txt/sprintf("%d%02d%02d.txt",$3,$2,$1)/ge' result_*.txt

Given a bunch of files with "wrong" date naming, it renames them in a "good" format.




commandlinefu.com


by David Winterbottom (codeinthehole.com)






from All commands http://ift.tt/1xSqqVc

No comments:

Post a Comment