iPhoneから取り込んだ写真とデジカメの写真を一緒に管理したいとき、ウェブから集めたフリー素材を一括管理したいときなど、いろんな名前の画像を共通ファイル名+連番にしたいときってありませんか?ターミナルが使えるMacを多用する機会が増え、自分で重宝しています(^^;
対象ファイルの拡張子が”jpg”、置換後のプレフィックス(ファイル名の共通文字部分)が”photo_”とした場合、
1 |
export prefix="photo_";export ext=".jpg";export cnt=`ls -1 *$ext | wc -l`; export n=1; for f in `ls -1 *$ext`; do mv $f ${prefix}`printf "%03d" ${n}`$ext; n=`expr $n + 1`; done |
で一括置換。
No comments yet. You should be kind and add one!
By submitting a comment you grant typista a perpetual license to reproduce your words and name/web site in attribution. Inappropriate and irrelevant comments will be removed at an admin’s discretion. Your email is used for verification purposes only, it will never be shared.