Hi!
Thanks for a great tool :) Just discovered it after some years using Shotwell under Linux.
In order to make my work flow better, I would like to make a script that looks in an upload folder and rename/moves the files into another folder structure.
- Upload folder: ./upload/(I autosynk my phones into this folder)
- Upload filename: varying naming formats.ext
- Photo folder: ./Photographs/YYYY/MM - Month/
- Filename: YYYYMMDD_HHMMSS.ext (jpg, mp4, NEF, CRW, CR2)
I've tried to follow guides on https://exiftool.org/filename.html but I can't seem to manage to rename files AND create new folders AND move them into the new folders in one step. Is it possible?
EDIT:
Even better would be if I can split videos and photographs into separate structures like this:
- Photo folder: ./Photographs/YYYY/MM - Month/
- Filename: YYYYMMDD_HHMMSS.ext (jpg, NEF, CRW, CR2)
- Video folder: ./Videos/YYYY/MM - Month/
- Filename: YYYYMMDD_HHMMSS.ext (mp4, mov)
Happy Christmas!
something like this maybe?:
exiftool '-testname<./${mimetype;$_=/video/ ? "Videos" : "Photographs"}/$createdate.%e' -d "%Y/%d - %B/%Y%m%d_%H%M%S" ./upload
Change "testname" to "filename" once you have it doing what you want.
- Phil
Wow, brilliant! This worked very well. Thank you!
Somehow there are duplicate filenames when I migrate the existing files (from the old structure). Is it possible to add a _2 etc on the duplucates?
Ps. A small typo inn the example I think.
"%Y/%d - %B/%Y%m%d_%H%M%S"
should be
"%Y/%m - %B/%Y%m%d_%H%M%S"
Quote from: Gatak on December 22, 2018, 09:05:16 AM
Is it possible to add a _2 etc on the duplucates?
Try adding
%+c, e.g.
$createdate%+c.%e.
See the
-w (textout) option (https://exiftool.org/exiftool_pod.html#w-EXT-or-FMT--textOut) for more details.
This is similar to what I want to do. I'd also like to change the file created date and file modified date to CreateDate. How would you add that to this?
Also, can you add the original filename into the new filename?
And just so i can learn this better, how does the above know which extensions are videos and which are photos anyway?
Quote from: StarGeek on December 22, 2018, 12:11:00 PM
Try adding %+c, e.g. $createdate%+c.%e.
See the -w (textout) option (https://exiftool.org/exiftool_pod.html#w-EXT-or-FMT--textOut) for more details.
Great. Thanks!
Quote from: lnjustin on December 22, 2018, 12:55:58 PM
This is similar to what I want to do. I'd also like to change the file created date and file modified date to CreateDate. How would you add that to this?
I used "-filemodifydate<CreateDate"
This seems to output a strange test directory structure for me:
'./video/quicktime/2018/07 - July/20180719_035909.mov'
Instead of Photos or Videos, the folder structure has the type of video? Any ideas?
Code was; /usr/local/bin/exiftool '-testname<./${mimetype;$_=/video/ ? "Videos" : "Photos"}/$createdate.%e' -d "%Y/%m/%Y%m%d_%H%M%S" -r DIR
I got two folders with this structure
/mnt/archive/Photographs/YYYY/MM - Month/
/mnt/archive/Videos/YYYY/MM - Month/
And each file, is named YYYYMMDD_HHMMSS.ext
Running from folder /mnt/archive:exiftool -v '-filename<./${mimetype;$_=/video/ ? "Videos" : "Photographs"}/$createdate.%e' -d "%Y/%d - %B/%Y%m%d_%H%M%S" /www/htdocs/nextcloud/data/__groupfolders/2/Photos/
Quote from: lnjustin on December 22, 2018, 01:53:19 PM
Code was; /usr/local/bin/exiftool '-testname<./${mimetype;$_=/video/ ? "Videos" : "Photos"}/$createdate.%e' -d "%Y/%m/%Y%m%d_%H%M%S" -r DIR
Make sure that you're using regular quotes
". Your example had a fancy quote
".
Quote from: Gatak on December 22, 2018, 01:21:38 PM
Quote from: lnjustin on December 22, 2018, 12:55:58 PM
This is similar to what I want to do. I'd also like to change the file created date and file modified date to CreateDate. How would you add that to this?
I used "-filemodifydate<CreateDate"
So the formatting with -d doesn't mess up still assigning CreateDate to filemodifydate? I thought -d formats CreateDate. When I did -d %Y/%m and assigned CreateDate to the Directory tag for moving files to YYYY/MM folders, but also assigned CreateDate to filecreationdate, the creation date was written as the first day of the month at midnight (day and time was lost because of -d formatting)
You can add a hashtag to the end of the tag name to prevent the print convert for that instant (see the -n (printConv) option (https://exiftool.org/exiftool_pod.html#n---printConv)). For example, "-filemodifydate<CreateDate#" will pass the value of CreateDate unmodified by the -d (dateFormat) option (https://exiftool.org/exiftool_pod.html#d-FMT--dateFormat).