News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

Copying directory structure

Started by Hugh, February 08, 2016, 11:11:56 AM

Previous topic - Next topic

Hugh

I have found that the command
exiftool -k -r -sep "; " "-Subject<XPKeywords" "C:\My Progs\ExifTool\Before" -o "C:\My Progs\ExifTool\After"
will recurse through and process all the files in subdirectories of the Before directory, but all the new files are put in After.

Is it possible to specify that the directory structure under Before is replicated under After?

Phil Harvey

Here is one way to do this:

1. cd C:

2. cd "\My Progs\ExifTool\Before"

3. exiftool -k -r -sep "; " "-Subject<XPKeywords" . -o "C:\My Progs\ExifTool\After\%d\"

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

Hugh


Hugh

I'm afraid I'm having trouble making this work from a Windows batch file. I've changed %d to %%d, so my batch file now reads:
cd C:
cd "\My Progs\ExifTool\Before"
"C:\My Progs\ExifTool\exiftool.exe" -k -r -sep "; " "-Subject<XPKeywords" . -o "C:\My Progs\ExifTool\After\%%d\"


However, ExifTool reports an error for every file:
Error: Error creating file: C:/My Progs/ExifTool/After/./Subfolder/IMG_5669.JPG - ./Subfolder/IMG_5669.JPG

There seems to be an extraneous dot in the output path.

Phil Harvey

I wouldn't thikn that the extra "." should matter (at least it doesn't on Mac/Linux systems), but you may be able to get rid of it like this:

cd c:
cd "\My Progs\ExifTool\Before"
"C:\My Progs\ExifTool\exiftool.exe" -k -r -sep "; " "-Subject<XPKeywords" * -o "C:\My Progs\ExifTool\After\%%d\"

I think this should work if the directory names in the Before directory don't have extensions.  However, it probably only work for files in subdirectories, and not in the main Before directory.

Alternatively, the failure could be caused by a permission problem.

- Phil

Edit: Another option would be to use the advanced features of %d to remove the root directories from this string.  See the -w option documentation for details
...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 ($).

Hugh

Thank you for your patience.

I'm afraid I don't know how to copy and paste ExifTool's error messages and I missed out /" from the output path when transcribing the error message. I'm sorry.

With my previous code, the error message was:
Error: Error creating file: C:/My Progs/ExifTool/After/./Subfolder/"/IMG_5669.JPG - ./Subfolder/IMG_5669.JPG

Replacing the dot before -o in the command with an asterisk results in the following error message:
Error: Error creating file: C:/My Progs/ExifTool/After/Subfolder/"/IMG_5669.JPG - ./Subfolder/IMG_5669.JPG
The dot has gone from the output path but the extraneous  /" or "/ is still there between directory name and filename.

The batch file (copied and pasted from my text editor) is exactly as follows:
cd C:
cd "\My Progs\ExifTool\Before"
"C:\My Progs\ExifTool\exiftool.exe" -k -r -sep "; " "-LastKeywordXMP<XPKeywords" "-Subject<XPKeywords" "-xmp:Rating<Rating" * -o "C:\My Progs\ExifTool\After\%%d\"

Phil Harvey

OK.  This appears to be a problem with escaping the quote.  Try using forward slashes instead of backward slashes.

I don't know all the ins and outs of escaping on the Windows command line, but this should solve the problem if the backslash is used for escaping.

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

Hugh

Excellent. That seems to have done the trick.

My batch file now reads:
cd C:
cd "\My Progs\ExifTool\Before"
"C:\My Progs\ExifTool\exiftool.exe" -k -r -sep "; " "-LastKeywordXMP<XPKeywords" "-Subject<XPKeywords" "-xmp:Rating<Rating" * -o "C:/My Progs/ExifTool/After/%%d/"


Thank you very much.