0

I'm using the following code to copy the exif data from one file to another using exiftool.

When directly run from command line,the tool is quick.But when the command is executed from a winform app,it takes much greater time.What is going wrong here? Please advice. Is there any alternative way to achieve this?

foreach(string cpath in filelist)
{
    string path = "-overwrite_original -TagsFromFile " + "\"" + file + "\"" +" "+ "\"" + outdir + "\\" + Path.GetFileNameWithoutExtension(file) + ext + "\"";
                        runCmd(path);
}

  public void runCmd(string command)
    {

        ProcessStartInfo cmdsi = new ProcessStartInfo("exiftool.exe");
        cmdsi.WindowStyle = ProcessWindowStyle.Hidden;
        cmdsi.Arguments = command;
        Process cmd = Process.Start(cmdsi);
        cmd.WaitForExit();    
    }
aschipfl
  • 33,626
  • 12
  • 54
  • 99
techno
  • 6,100
  • 16
  • 86
  • 192
  • And how big is filelist? Is it slow from the first file or becomes slower over time? How slow (1 second, 10)? – Evk Apr 24 '18 at 09:24
  • @Evk The result is the same irrespective of the list size.I have tried with a single file.The file is high resolution 6000×4000 pixels.Directly the process completes in 1 second ,from winforms it takes ~3 seconds – techno Apr 24 '18 at 09:28
  • If you are running this on multiple files, one problem is covered by [Common Mistake #3](https://sno.phy.queensu.ca/~phil/exiftool/mistakes.html#M3). The startup time for exiftool is the biggest time cost, so running exiftool separately for each file will dramatically increase the overall run time. Consolidating the file list into a single command or saving the list to a temp file and using the [`-@` option](https://sno.phy.queensu.ca/~phil/exiftool/exiftool_pod.html#ARGFILE) will decrease the run time. – StarGeek Apr 24 '18 at 15:03
  • @StarGeek Thanks for your input,the startup time seems to be the culprit.I can write the list to a file,but how can i pass the output argument? Can you please add an example... – techno Apr 24 '18 at 15:46
  • Continuing on your [exiftool forum thread](http://u88.n24.queensu.ca/exiftool/forum/index.php/topic,9121.0.html), as that is better suited to posting examples than commenting here. – StarGeek Apr 24 '18 at 16:37
  • @StarGeek Thanks :),i will follow-up there.. – techno Apr 24 '18 at 16:43

0 Answers0