Hello all!
First of all:
I've been working with the exiftool GUI a long time.
Right now I'm trying to expand the my usage of the exiftool by writing a batch which has the requirement to:
- move the images to a subfolder %Y based on DateTimeOriginal of each image
- rename the image to %y%m%d_%H%M%S_%%f.%%e
And here is the first solution:
...
%EXIFTOOL% -r -d %BACKUPPATH%\%%Y\%%y%%m%%d_%%H%%M%%S_%%%%f.%%%%e "-filename<DateTimeOriginal" %INPUTPATH%
...During the first tests everything was working fine.
The variable
%BACKUPPATH% has set to a absolute directory on my HDD (e.g.
C:\temp\).
Then I changed the
%BACKUPPATH% to an UNC-Path
\\SERVER\PATH.
The batch is now executing without any error, but the files aren't copied to the folder
\\SERVER\PATH\. They are copied to the path
\SERVER\PATH on my HDD.
I'm thankful for every hint of how I can pass UNC-Paths to exiftool.
Regards
Daniel
Hi Daniel,
If you had Perl installed on your system it may help for testing. The problem is likely due to how Perl handles UNC paths. According to this reference (http://www.informit.com/articles/article.aspx?p=29311), you should be able to specify UNC paths with either forward slashes or backwards slashes in Perl. Internally, ExifTool will convert backslashes to forward slashes then tests to see if the directory part of the path name exists. As a Perl command line, this would be equivalent to:
perl -e "print qq{yes\n} if -d '//SERVER/PATH/'"
I must say, I don't understand UNC paths, because on Unix/Mac systems specifying "/DIR" is equivalent to "//DIR".
Another option is if you could make a hard link from a real directory on your hard disk to a UNC path, but I'm not sure if this would be possible.
Perhaps a Windows expert would have more ideas here.
- Phil
Hi Phil!
First of all thanks for your fast reply.
I just installed cygwin to easily run perl.
With your command
perl -e "print qq{yes\n} if -d '//SERVER/PATH/'"
I got the response
yes.
Testing with
\\SERVER\PATH\
was not successful as I got the response
Can't find string terminator "'" anywhere before EOF at -e line 1..
So I tried
\\\\SERVER\\PATH\\
to fit the escape sequences on the bash and got the same response.
I think I will check if its possible to temporary mount the UNC path to a defined drive (if it isn't yet mounted).
Another way would be to perform the exiftool options in a temp-folder and after that copy the files by the batch-file.
Never the less, if somebody has a solution for the UNC path handling I would be pleased to read the solution here. ;)
Regrads
Daniel
Hi Daniel,
Quote from: yet_another_photographer on September 30, 2010, 05:18:59 AM
With your command
perl -e "print qq{yes\n} if -d '//SERVER/PATH/'"
I got the response
yes.
This makes me hopeful that it should work with exiftool (assuming that '/SERVER/PATH' didn't also exist on your system). But the problem is I don't have access to your system so you will have to do all the testing if you can. For these tests, run the pure Perl version of exiftool and replace the CreateDirectory() function at line 2247 of "exiftool" with the following:
#------------------------------------------------------------------------------
# Create directory for specified file
# Inputs: 0) complete file name including path
# Returns: true if a directory was created (dies if dir can't be created)
sub CreateDirectory($)
{
my $file = shift;
my ($dir, $created);
($dir = $file) =~ s/[^\/]*$//; # remove filename from path specification
print "System=$^O\n";
print "File='$file'\n";
print "Dir='$dir'\n";
if ($dir and not -d $dir) {
my @parts = split /\//, $dir;
$dir = '';
foreach (@parts) {
$dir .= $_;
print "B '$dir'\n";
if (length $dir and not -d $dir) {
# create directory since it doesn't exist
mkdir($dir, 0777) or Die "Error creating directory $dir\n";
$verbose and print "Created directory $dir\n";
$created = 1;
print "Created '$dir'\n";
}
$dir .= '/';
}
}
++$countNewDir if $created;
return $created;
}
Here I have inserted a few print statements to trace through the program flow.
Try running this version of exiftool with your command and let me know what it prints.
Thanks.
- Phil
Hi Phil!
I just made some test runs with the modifications you stated before.
The content of the batch is build up like
SET BACKUPPATH=\\nautilus\picture\Test
rem INPUTPATH given as argument
SET INPUTPATH=%1
perl exiftool -r -d %BACKUPPATH%/%%Y/%%y%%m%%d_%%H%%M%%S_%%%%f.%%%%e "-filename<DateTimeOriginal" %INPUTPATH%"
Here's the result while running it from a batch
D:\bin\Image-ExifTool>perl exiftool -r -d \\nautilus\picture\Test/%Y/%y%m%d_%H%M%S_%%f.%%e "-filename<DateTimeOriginal" D:\temp\TestPicture_0002.JPG"
cygwin warning:
MS-DOS style path detected: D:/temp/TestPicture_0002.JPG
Preferred POSIX equivalent is: /cygdrive/d/temp/TestPicture_0002.JPG
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
System=cygwin
File='/nautilus/picture/Test/2009/090717_214919_TestPicture_0002.JPG'
Dir='/nautilus/picture/Test/2009/'
1 image files updated
What we can see is that cygwin gives a warning about the Linux- and DosStylepathes.
I think for your analysis the lines System, File and Dir should be interessting.
I think the mixture of \ and / in the call of exiftool doesn't matter or what do you think.
What I can observe is that the file 090717_214919_TestPicture_0002.JPG is stored to D:\nautilus\picture\wink\Backup\Test\2009\091117_181052_IMG_1551.JPG.
Cheers Daniel
Hi Daniel,
I FOUND IT! Thanks!! Your testing was very helpful.
In my code I am specifically converting "//" to "/" in the path, so it is my fault.
Try changing line 2182 of exiftool from
$filename =~ s{//}{/}g; # remove double slashes
to
$filename =~ s{(?!^)//}{/}g; # remove double slashes except at start
If it works, I will include this change in the next release [version 8.33].
- Phil
Edit: Added "next release" version number
Hi Phil!
To cut the long story short. - It works! ;D
And now the long story.
I just replaced the line 2182 in exiftool and started the batch.
System=cygwin
File='//nautilus/picture/Test/2009/090717_214919_TestPicture_0003.JPG'
Dir='//nautilus/picture/Test/2009/'
B ''
B '/'
B '//nautilus'
B '//nautilus/picture'
B '//nautilus/picture/Test'
B '//nautilus/picture/Test/2009'
Created '//nautilus/picture/Test/2009'
1 directories created
1 image files updated
The file is copied to the UNC-path on the server.
Thanks for your quick and successful help.
Cheers Daniel
Great! Thanks for your help in fixing this!
- Phil