Maintain Original Directory Structure...

Started by captured, November 03, 2018, 07:56:17 PM

Previous topic - Next topic

captured

Hello.

I usually only use exiftool for images only.

Is it possible to use exiftool to maintain the original parent directory structue,
and organize contents with new sub directories "%Y-%m" ?

Original;
Camera/
├──2017-08-31/
      ├── 2017-08-10  P_20170810_083218.jpg
      ├── 2017-08-10  P_20170810_091921.jpg
      ├── 2017-08-10  P_20170810_083116.jpg
      ├── 2017-08-26  P_20170826_141554.jpg
      ├── 2017-08-26  P_20170826_134822.jpg
      ├── 2017-08-26  P_20170826_135639.jpg
      ├──2017-08-08/
            ├── 2017-08-08 P_20170809_091916.jpg
            └── 2017-08-08 P_20170809_090630.jpg


Desired Result;
├──2017-08/
   ├──2017-08-10/
   │   ├── P_20170810_083218.jpg
   │   ├── P_20170810_091921.jpg
   │   ├── P_20170810_083116.jpg
   ├──2017-08-26/
   │   ├── P_20170826_141554.jpg
   │   ├── P_20170826_134822.jpg
   │   ├── P_20170826_135639.jpg
   ├──2017-08-08/
   │   ├── P_20170808_091916.jpg
   │   └── P_20170808_090630.jpg

So, if exiftool encounters a parent directory, copy that directory named as is,
but sub catagorize files inside by date with directory "%Y%m%d"

My articulation is a little off today.

Thank you.

Phil Harvey

#1
Sure.  You want to keep the top-level directory name, then split the FileName on a space and use the first part for the next-level directory?:

exiftool "-testname<DSTDIR/${createdate}/%-1:d${filename;s/ .*// or $_=undef}/${filename;s/.*? //}" -d %Y-%m -r SRCDIR

If this does what you want, then replace "testname" with "filename" to actually copy the files.

Here the first advanced formatting expression returns "undef" if there was no space in the file name to avoid copying these files (you'll get a warning instead).

- Phil

Edit:  Added the top-level %Y-%m directory that you wanted, based on CreateDate

Edit2: Wait.  Looking again at your example it seems that you don't want to keep the original parent directory at all as I thought you were saying.  In this case, just drop %-1:d from the expression.
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

captured

Thanks, as usual Phil.

It's hard to explain visually what I am trying to achieve.
I have folders that are by Year-Month YYYY-MM.
So for Parent folder 2018-10/
The subfolder contents should all be in year 2018, month 10,  e.g.
2018-10-30
2018-10-30_Camera-02
P_2018-10-31_Cam-02.jpg
P_2018-10-31_Cam-02.dng

I was hoping to use exiftool to organize sub folders by date YYYY-MM-DD, I'm brain-cramping at the moment
because in the above example, the "2018-10-30_Camera-02" folder will have to move inside "2018-10-30"
and the .jpg and .dng would have to move into a new directory "2018-10/2018-10-31/.

Could be confusing myself in a tangled web.
I'll try to apply your formula and see if I can make it work.

Thanks again.

Best regards.