Subfolders ( -r does not work )

Started by MartyProtiProudu, February 14, 2024, 06:46:27 AM

Previous topic - Next topic

MartyProtiProudu

Hi there ! I am trying to figure out how to make this work.

So lets say, I have some files I would like to copy metadata from in folders:

V:\! Hamburg Trip - Orig\Day 00\D00 - Orig
V:\! Hamburg Trip - Orig\Day 01\D01 - Orig
V:\! Hamburg Trip - Orig\Day 02\D02 - Orig

And so on about 70 folders now.

I fix some files in editor ( Davinci Resolve Studio ), I export them to:

W:\Fixed

Now, I want EXIF, to look into folder and all subfolders in:

V:\! Hamburg Trip - Orig\

Than take all those metadata and apply them to whatever files are in:

W:\Fixed

When I used -R, it did not work, as I assume, that R is trying to do same subfolder structure.

Example of my command:

exiftool -api largefilesupport=1 -ee -r -progress:%%50b -overwrite_original -TagsFromFile "V:\! Hamburg Trip - Orig/"%%F -All:All -FileModifyDate -FileCreateDate "W:\Fixed/"

This results in cmd printing error opening files, but it prints all files in the subfolders of "V:\! Hamburg Trip - Orig

So in short:

Scan FOLDER and SUBFOLDERS of "c:\myawesomevideos\" and take metadata from whatever videos are in the "C:\myawesomevideos\ and SUBFOLDERS" than copy them to files with same name in "d:\metadatafixed"

PS: How can I make this command to skip files that already have correct metadata ?

Phil Harvey

There is no way to determine the directory of the source file if you are looking at the fixed files which are all stored together in the same directory.  So you need to scan the original files instead, and use the tricky -srcfile option to specify the fixed file as the target.

exiftool -api largefilesupport=1 -ee -r -progress:%%50b -overwrite_original -TagsFromFile @ -All:All -FileModifyDate -FileCreateDate -srcfile "W:\Fixed/"%%F "V:\! Hamburg Trip - Orig/"

Note that you'll get errors for any original file that doesn't have a corresponding fixed file.

Skipping files that already have metadata is difficult.  I have to think about this a bit.

- Phil
...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 ($).

Phil Harvey

OK, here you go.  This uses the advanced -fileNUM option to test for the existence of EXIF in the fixed file, and doesn't copy tags from the original if found.  Here I'm testing File1:EXIF:All which will be true if any EXIF exists in the target, but you can test any other tag(s) that you want.

exiftool -api largefilesupport=1 -ee -r -progress:%%50b -overwrite_original -TagsFromFile @ -All:All -FileModifyDate -FileCreateDate -srcfile "W:\Fixed/"%%F -file1 "W:\Fixed/"%%F -if "not $file1:exif:all" "V:\! Hamburg Trip - Orig/"

- Phil
...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 ($).

MartyProtiProudu

Thank you Phil. Ill give it a shot bit later.

StarGeek

Just to verify, your source files are
V:\! Hamburg Trip - Orig\Day 00\D00 - Orig\File1.mp4
V:\! Hamburg Trip - Orig\Day 01\D01 - Orig\File2.mp4
V:\! Hamburg Trip - Orig\Day 02\D02 - Orig\File3.mp4

But the fixed files do not include any subdirectories, e.g.
W:\Fixed\File1.mp4
W:\Fixed\File2.mp4
W:\Fixed\File3.mp4

Is that correct?

Quote from: MartyProtiProudu on February 14, 2024, 06:46:27 AMWhen I used -R, it did not work, as I assume, that R is trying to do same subfolder structure.

The -r (-recurse) option only recurses into the target directories subfolders.  It doesn't do anything to apply the directory structure to the target files.

The place to keep track of the folder structure is in the format string directly after the -TagsFromFile option using the %d variable.  You would strip away the top level directories with the %:#d where # is the number of top level directories you want to strip away.  See the -w (-TextOut) option for details on the percent variables and how to edit them.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

MartyProtiProudu

Quote from: StarGeek on February 14, 2024, 10:48:51 AMJust to verify, your source files are
V:\! Hamburg Trip - Orig\Day 00\D00 - Orig\File1.mp4
V:\! Hamburg Trip - Orig\Day 01\D01 - Orig\File2.mp4
V:\! Hamburg Trip - Orig\Day 02\D02 - Orig\File3.mp4

But the fixed files do not include any subdirectories, e.g.
W:\Fixed\File1.mp4
W:\Fixed\File2.mp4
W:\Fixed\File3.mp4

Is that correct?


Yes, that is correct.

In best case scenario, I would like to do following:

Original videos would be somewhere on drive V: - in folders, subfolders etc., like so:
V:\Folder1\File1.mp4
V:\Folder2\Subfolder1\file2.mp4
V:\Folder2\Subfolder5\file3.mp4

Fixed videos would be somewhere on drive W: - in folders, subfolders etc., like so:
W:\File1.mp4
W:\Random folder\file2.mp4
W:\Another random folder\Subfolder\file3.mp4

Now, I would like the exiftool to copy ALL metadata from files on V to W ( ignoring folder structure )
- also, not update any files that already have same metadata
- also, support large files
- also, overwrite original
- also, show progress (% would be better than those dots )
- also, make sure that ALL data is copied from V to W