bash - How to decrement a number in each filename in a directory? -
running "ls -lrt" on terminal large list looks this:
-rw-r--r-- 1 pratik staff 1849089 jun 23 12:24 cam13-vid.webm -rw-r--r-- 1 pratik staff 1850653 jun 23 12:24 cam12-vid.webm -rw-r--r-- 1 pratik staff 1839110 jun 23 12:24 cam11-vid.webm -rw-r--r-- 1 pratik staff 1848520 jun 23 12:24 cam10-vid.webm -rw-r--r-- 1 pratik staff 1839122 jun 23 12:24 cam1-vid.webm
i have shown part of above sample.
i rename files have number 1 less current.
for example,
mv cam1-vid.webm cam0-vid.webm mv cam2-vid.webm cam1-vid.webm ..... .... mv cam 200-vid.webm cam199-vid.webm
how can done using os x / linux bash script (perhaps using sed) ?
you can plain bash:
for in {1..200} mv "cam${i}-vid.webm" "cam$((i-1))-vid.webm" done
Comments
Post a Comment