ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: Lectrician on October 23, 2011, 06:23:57 AM

Title: Move and create dirs
Post by: Lectrician on October 23, 2011, 06:23:57 AM
I currently have some software which uses WiFi to sync all my photos from my iPhone to my server which works great, but I end up with a single directory full of images.

I found this software and it appears it should be able to help me, although I am struggling to get it to do exactly what I want!

I am running it through CMD and would like to create a batch file which will run under scheduled tasks.

I would like it to read all images in the base dir and move them into folders like Oct_2011, Oct_2012 (or 10_2011, 10_2012).

Is this possible with a single command?

Thanks for any help!
Title: Re: Move and create dirs
Post by: Phil Harvey on October 23, 2011, 07:17:43 AM
To do this, just copy any date/time tag to the "Directory" tag with the desired date/time formatting.

See the application documentation renaming examples (https://exiftool.org/exiftool_pod.html#renaming_examples) for some examples, and the writing "FileName" and "Directory" tags (https://exiftool.org/filename.html) documentation for more details.

- Phil
Title: Re: Move and create dirs
Post by: Lectrician on October 29, 2011, 01:50:46 PM
Sorry for not thankyou earlier, I have only just had chance to revisit this, and will be trying again soon!

Thanks for the pointers.
Title: Re: Move and create dirs
Post by: Lectrician on October 30, 2011, 12:13:06 PM
Quick update.  I have it working.  After re-reading the info I realised I needed to alter the variables when using it through a batch file.

Here is what I am using:


##start batch file##
set mbasedir="D:/Users Shared Folders/Martin/My Pictures/iPhone"
set kbasedir="D:/Users Shared Folders/Katie/My Pictures/iPhone Photos"

exiftool -d %mbasedir%/%%Y/(%%m)-%%b "-directory<CreateDate" %mbasedir%
exiftool -d %mbasedir%/%%Y/(%%m)-%%b "-directory<FileModifyDate" %mbasedir%

exiftool -d %kbasedir%/%%Y/(%%m)-%%b "-directory<CreateDate" %kbasedir%
exiftool -d %kbasedir%/%%Y/(%%m)-%%b "-directory<FileModifyDate" %kbasedir%
##end batch file##



It will move any images from the base director into folders like:
\2010\(01)-Jan
\2010\(05)-May
\2011\(09)-Sep
\2011\(12)-Dec

I chose to have "(12)-Dec" to allow quick find by visual month, but the numbers in brackets put the folders in month order (Jan, Feb, March etc), rather than true alphabetically which would end up with Apr, Aug, Dec, Nov, which is not helpful!

I have run both CreateDate and FileModifyDate to ensure any images without exif data (for whatever reason) are moved too.

I would like to get this work with my iPhone videos too (*.MOV), but do not think I can do this??

Title: Re: Move and create dirs
Post by: Phil Harvey on October 30, 2011, 01:06:13 PM
Looks good.  If you specify MOV it will work for them too (a-la FAQ 16).  Also, you can combine this into a single command.  When you copy different tags to Directory, the last one takes precedence, so we do CreateDate after FileModifyDate:

##start batch file##
set mbasedir="D:/Users Shared Folders/Martin/My Pictures/iPhone"
set kbasedir="D:/Users Shared Folders/Katie/My Pictures/iPhone Photos"

exiftool -d %%%%d%%Y/(%%m)-%%b "-directory<FileModifyDate" "-directory<CreateDate" -ext jpg -ext mov %mbasedir% %kbasedir%

##end batch file##


- Phil
Title: Re: Move and create dirs
Post by: Lectrician on October 31, 2011, 05:17:33 PM
Thats great, thank you, it works perfectly!  I have also added a "-ext png" for screen shots stored on the iPhone.

I am a little confused by the bit in red below!  I can see it works perfectly, but can't quite see how/what this bit is?

exiftool -d %%%%d%%Y/(%%m)-%%b "-directory<FileModifyDate" "-directory<CreateDate" -ext jpg -ext mov %mbasedir% %kbasedir%
Title: Re: Move and create dirs
Post by: Phil Harvey on October 31, 2011, 06:30:41 PM
Quote from: Lectrician on October 31, 2011, 05:17:33 PM
I am a little confused by the bit in red below!  I can see it works perfectly, but can't quite see how/what this bit is?

exiftool -d %%%%d%%Y/(%%m)-%%b "-directory<FileModifyDate" "-directory<CreateDate" -ext jpg -ext mov %mbasedir% %kbasedir%

You'll find all of the details in the documentation I referenced, but the bottom line is that this represents the directory of the source file.

- Phil