Author Topic: Possible to skip nonexistent files/folders when writing from csv?  (Read 3330 times)

3design

  • Jr. Member
  • **
  • Posts: 29
I'm using the following command line to write tags to a folder of folders, each containing a number of image files:

exiftool -csv=tagindex.csv -sep ", " -P -ext jpg -r .

The csv contains references to hundreds of folders and dozens of files in each folder. Some of those folders may not exist in this particular "run". Is it possible to skip, or ignore, files or folders which may be referenced in the csv but which do not exist in the directory structure? It would make it easier to use one master csv file for my entire project and not have to worry about which subfolders might not be included in this run.

3des

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14937
    • ExifTool Home Page
Re: Possible to skip nonexistent files/folders when writing from csv?
« Reply #1 on: April 01, 2014, 10:44:38 AM »
The -csv option does not specify the files to process.  The files are specified on the command line.  Any extra entries in the CSV file are ignored, and missing entries will give an error.  This seems to be exactly what you want.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

3design

  • Jr. Member
  • **
  • Posts: 29
Re: Possible to skip nonexistent files/folders when writing from csv?
« Reply #2 on: April 01, 2014, 11:21:52 AM »
Oh, so I would need to include all the filenames in the command line...

I used to run the command above only after filtering the CSV file to include only the subfolders that existed on the filesystem for that particular run, but that's a nuisance because the csv contains thousands of files in subfolders and I may only be writing to some random few dozens of them. For example, when I run the command above using a master CSV, which may contain references to:

./mainfolder/subfolder01/file.jpg
./mainfolder/subfolder02/file.jpg
./mainfolder/subfolder03/file.jpg

on a folder structure which contains only:

./mainfolder/subfolder01/file.jpg
./mainfolder/subfolder02/file.jpg

It gives me an error similar to:

./mainfolder/subfolder03/file.jpg: No such file or directory at script/exiftool line 1497.

I was hoping to be able to use the same CSV on any folder structure, and have exiftool ignore images that don't exist on the filesystem. So it seems I need to either:
1. filter the csv to contain only the folders that I'm writing in a particular run (as I've been doing in the past), or
2. create a customized command line for each run which contains the name of each file to be processed from a csv which may contain more files than are being written in that run

3des

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14937
    • ExifTool Home Page
Re: Possible to skip nonexistent files/folders when writing from csv?
« Reply #3 on: April 01, 2014, 11:27:32 AM »
In your original command, you gave "." to process all files in the current directory, with the -r option to also process images in sub-directories.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

3design

  • Jr. Member
  • **
  • Posts: 29
Re: Possible to skip nonexistent files/folders when writing from csv?
« Reply #4 on: April 01, 2014, 02:19:48 PM »
Ok, I'm not sure I understand your reply, or at least not the point you're making.. Yes, I do have the "." to process based on the current directory and the -r to process sub-directories. When my CSV contains ALL or LESS THAN the files on the filesystem, that command works perfectly, but if the CSV contains MORE THAN the actual files in the filesystem, it doesn't work.

It seems to me that something is wrong in the path but I don't understand why the command I've been using all along works just fine as long as the CSV references match the files in the filesystem. As soon as there's a reference in the CSV to a file that is *not* on the filesystem, the command doesn't work.

If this is by design, would you consider adding a switch to ignore csv references to non-existent files? Basically I'm just trying to find a simple way to use the same csv file on multiple directories and not have to worry about which files are actually in that directory structure. Since all my csv references begin with ./ I was hoping the same csv could be used on any top-level folder using the same exiftool command, regardless of which files are in that specific directory structure. Maybe something like:

-ignoremissing
When used in conjunction with '-csv=' EXIFTool will disregard rows in the CSV which reference non-existent files.

This way you can maintain one master csv file with all your images in it. Then when you prep a subset of those images, you just drop them under your csv file location, and use the same command and same csv every time without having to worry about which files we're working on, which csv references exist, which don't, etc. Does this make sense? Does EXIFTool already do this and I'm just totally missing how?

3des

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14937
    • ExifTool Home Page
Re: Possible to skip nonexistent files/folders when writing from csv?
« Reply #5 on: April 01, 2014, 02:22:43 PM »
but if the CSV contains MORE THAN the actual files in the filesystem, it doesn't work.

I don't understand.  Why doesn't it work?  As I said, extra CSV entries should be ignored.

More details are required other than just "it doesn't work".

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14937
    • ExifTool Home Page
Re: Possible to skip nonexistent files/folders when writing from csv?
« Reply #6 on: April 16, 2014, 07:50:51 PM »
I just got a report from another Windows user about a similar problem.  Apparently the Windows version gives an error like this then quits if any SourceFile in the CSV doesn't exist:

FILE: No such file or directory at script/exiftool line 1509

This problem only happens in Windows, and it will be fixed in ExifTool 9.58

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

3design

  • Jr. Member
  • **
  • Posts: 29
Re: Possible to skip nonexistent files/folders when writing from csv?
« Reply #7 on: May 21, 2014, 06:29:57 AM »
Great. Not sure if it's the same error I was getting:

./mainfolder/subfolder03/file.jpg: No such file or directory at script/exiftool line 1497

but the conditions appear similar to what you describe.

3des

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14937
    • ExifTool Home Page
Re: Possible to skip nonexistent files/folders when writing from csv?
« Reply #8 on: May 21, 2014, 07:08:22 AM »
Try updating to the current version of ExifTool.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).