Alreet.Sometimes Mendeley content has to move. There’s
Following Robert Seale’s advice, I was looking for a solution to batch rename photo files. After my last shoot I used digikam and while the results were as desired, it took a second or more per image, which I thought a bit long. After not finding a different suitable solution I asked the question on unix.stackexchange and was overwhelmed by two people’s in-depth answers. I learned a lot from both mikserv and Gilles and in the end settled with Gilles’ suggestion. I take zero credit for the solution, I don’t even understand parts of what is going on, but I amended it a little bit nonetheless and thought the extended version might help someone.*
What I get when I come home is file names looking like this:
_DSC1234.NEF. What I wanted instead was
- date-shot in YYYYMMDD-format plus
- a descriptive shoot-name plus
looking like this:
There are a few issues with this:
ad 1. Date Shot: sometimes I can only copy and rename the files a few days after shooting, so the date should reflect the date the picture was taken, not the date it was copied. Getting date-shot from the file itself is difficult as there is no birth time recorded. The closest is
mtime which is the time the file’s content has last been modified. However, creation date is stored in image file’s EXIF data.
ad 2: Name of Shoot: Ideally I wanted this to be a variable I could set as a parameter when calling the script.
ad 3. Number of Image: This should reflect the age of the image with the oldest one having the lowest number. The problem is that cameras usually restart numbering at
0000 once they hit
9999. So images n-9999 can potentially be older than 0000-n. I needed a solution that would cater for this special case.
# original solution by @Gilles (http://unix.stackexchange.com/questions/141138/) # set base
Recently I bought a faulty pack of grapefruit juice. The plastic nozzle was not glued to the carton properly, so instead of filling my glass, I filled
Says Mira Maier, founder of MyStipendium.de:
One in five foundations does not receive suitable applications, thus they don’t know