EXIF Info..
EXIF Info..
I'm really sorry if this topic has been discussed.. But based on my search, most results are only concern about the date and time.
But what I really want is to rename file based on other EXIF info e.g. camera model.
So, is it possible?
Thank you so much.
But what I really want is to rename file based on other EXIF info e.g. camera model.
So, is it possible?
Thank you so much.
Re: EXIF Info..
Hy there.aimy wrote:But what I really want is to rename file based on other EXIF info e.g. camera model.
In XYplorer help > Advanced Topics > Varables
is only this found
<dateexif> EXIF date of the current list item
But here is >> "Exiv2, a command line utility", found at >> http://www.exiv2.org/#util
Example:
http://www.exiv2.org/sample.html
Code: Select all
$ exiv2 img_1771.jpg
File name : img_1771.jpg
File size : 32764 Bytes
MIME type : image/jpeg
Image size : 480 x 360
Camera make : Canon
Camera model : Canon PowerShot S40
Image timestamp : 2003:12:14 12:01:44
Image number : 117-1771
With this utility one could create an script like
Dummy code:
Code: Select all
$EXIF = exiv2 <curitem>
For Each Item In $EXIF
{
if found "Camera model"
$output = split line at : colon
}
rename file $output*
Maybe someone have already played around with Exiv2?
Re: EXIF Info..
Ah, i forget about properties()
See this info > http://www.xyplorer.com/xyfc/viewtopic. ... 592#p39592
(There is mentioned an other command line exif tool too: ExifTool: http://www.sno.phy.queensu.ca/~phil/exiftool/)
The syntax of script command property you will find in help.
That combined with an rename command could be like this
working test command
For more info see XY help > Advanced > Scripting commands
The known properties your system provide you can see under menu "Tools > Config > File Info Tips" at the right.
See this info > http://www.xyplorer.com/xyfc/viewtopic. ... 592#p39592
(There is mentioned an other command line exif tool too: ExifTool: http://www.sno.phy.queensu.ca/~phil/exiftool/)
The syntax of script command property you will find in help.
That combined with an rename command could be like this
working test command
Code: Select all
$CamMod = property("CameraModel");
rename b, "$CamMod - *", p;
The known properties your system provide you can see under menu "Tools > Config > File Info Tips" at the right.
Re: EXIF Info..
Thank you so much...Stefan wrote:Ah, i forget about properties()
See this info > http://www.xyplorer.com/xyfc/viewtopic. ... 592#p39592
(There is mentioned an other command line exif tool too: ExifTool: http://www.sno.phy.queensu.ca/~phil/exiftool/)
The syntax of script command property you will find in help.
That combined with an rename command could be like this
working test commandFor more info see XY help > Advanced > Scripting commandsCode: Select all
$CamMod = property("CameraModel"); rename b, "$CamMod - *", p;
The known properties your system provide you can see under menu "Tools > Config > File Info Tips" at the right.
So now, I have a script button with this command..
Code: Select all
$CamMod = property("CameraModel");
rename b, "<dateexif yyyymmdd.hhnnss>~*_$CamMod", p;
But what if I want to cater a case where the picture missed the EXIF info?
In this case for example, it would be renamed as ~08102010066_.jpg which is not proper. So, I want it to retain the original filename if no EXITFfound in the file. Could I do that within a one script?
Thanks a lot.
Re: EXIF Info..
Currently i have no idea how to code this in a proper way.aimy wrote:But what if I want to cater a case where the picture missed the EXIF info?
So, I want it to retain the original filename if no EXITFfound in the file.
Could I do that within a one script?
This script will handle each file at its one
and ask you if the new name is correct.
This is handled by the "p" switch in the rename() command.
I expected to see all selected files in the renaming preview
instead showing an preview for every single file.
You can remove the "p" after you have checked a few files if it worked correct, but...
I'am sure someone will have an better idea.
And, if i cancel the rename-preview-dialog called from the script,
the script-debugging dialog appears telling me the renaming was canceled
If i cancel an renaming-dialog called from context menu i get no such info.
Code: Select all
$list = get("SelectedItemsPathNames", "|");
$index=1;
while(true)
{
//get one after the other file from file list $file:
$file = gettoken($list, $index, "|");
if ($file==""){break;}
//read property from actual file:
$CamMod = property("CameraModel", $file);
//trim space and tabs around the reported property:
$CamMod = regexreplace($CamMod, "\s*|\t*(.*)\s*|\t*", "$1");
//msg "Debug: #$CamMod#",1;
//rename only if there is no emtpy property:
if ($CamMod != "")
{
rename b, "<dateexif yyyymmdd.hhnnss>~*_$CamMod", p, $file;
//rename b, "<dateexif yyyymmdd.hhnnss>~*_$CamMod", , $file;
}
//next file:
incr $index;
if ($index > 1000){break;} //prevent infinity loop while script testing
}
Last edited by Stefan on 11 Feb 2011 21:06, edited 1 time in total.
Re: EXIF Info..
Stefan, thanks a lot for your effort, I really appreciate..
Yeah, I just noticed that my simple script above would not preview the file name correctly if I select multiple files.
It would only show up to the dateexif renaming, not the camera model.
Yeah, I just noticed that my simple script above would not preview the file name correctly if I select multiple files.
It would only show up to the dateexif renaming, not the camera model.
Re: EXIF Info..
You may also use an third-party tool called Siren as additional renamer tool
Example:
FROM:
DSC00090.JPG
TO:
20080818_184633~DSC00090_K800i.JPG
First read and do this >>> http://scarabee-software.net/forum/viewtopic.php?id=228
To start Siren from XYplorer dir paste this into the XYplorer Addressbar:
::run """<xypath>\Siren.exe"" <selitems>"; //rename the items currently selected
Now you can see an preview of all files in that folder
and start renaming only of the in XY selected files in Siren.
Your expression for Siren for your case would be something like:
%Xdo~%b_%Xmo.%e
but if there is no exif info about camera model
this would lead to an result like:
~DSC00090_.JPG
So i add an second expression
to catch names with an leading '~' and an trailing '_'
and remove this signs again:
%Xdo~%b_%Xmo.%e;%fc(s/^~(.+)_/\1/)
Now take an look at the preview and start renaming.
Of course that can be done with XYplorer itself too, but the advantage of an tool like Siren is the preview.
Short Explanation of the expression:
%Xdo~%b_%Xmo.%e;%fc(s/^~(.+)_/\1/)
%Xdo >>> an date (i hope the taken date?)
~
%b >>> base name without extension
_
%Xmo >>> exif info camera
.
%e >>> original extension
; >>> delimiter for next expression
%fc >>> complete (calculated) filename
(s/^~(.+)_/\1/) >>> regular expression: find "~" than (one-or-more of any sign) till an "_", then replace with what is matched between the "(...)"
Your result may vary if your file names have an different format / position of signs.
Hope that makes sense and helps
Example:
FROM:
DSC00090.JPG
TO:
20080818_184633~DSC00090_K800i.JPG
First read and do this >>> http://scarabee-software.net/forum/viewtopic.php?id=228
To start Siren from XYplorer dir paste this into the XYplorer Addressbar:
::run """<xypath>\Siren.exe"" <selitems>"; //rename the items currently selected
Now you can see an preview of all files in that folder
and start renaming only of the in XY selected files in Siren.
Your expression for Siren for your case would be something like:
%Xdo~%b_%Xmo.%e
but if there is no exif info about camera model
this would lead to an result like:
~DSC00090_.JPG
So i add an second expression
to catch names with an leading '~' and an trailing '_'
and remove this signs again:
%Xdo~%b_%Xmo.%e;%fc(s/^~(.+)_/\1/)
Now take an look at the preview and start renaming.
Of course that can be done with XYplorer itself too, but the advantage of an tool like Siren is the preview.
Short Explanation of the expression:
%Xdo~%b_%Xmo.%e;%fc(s/^~(.+)_/\1/)
%Xdo >>> an date (i hope the taken date?)
~
%b >>> base name without extension
_
%Xmo >>> exif info camera
.
%e >>> original extension
; >>> delimiter for next expression
%fc >>> complete (calculated) filename
(s/^~(.+)_/\1/) >>> regular expression: find "~" than (one-or-more of any sign) till an "_", then replace with what is matched between the "(...)"
Your result may vary if your file names have an different format / position of signs.
Hope that makes sense and helps
Re: EXIF Info..
Thank you so much stefan.. May God bless you..
But I was wondering.. Since u have proven that XYplorer could read the CameraModel property, why it is so difficult to achieve batch rename?
I've tried many times and many ways playing around with that property("CameraModel") but to no avail. It will always read the first selected file info only
I'm not really good at programming, but I like to do it when I know that it can be achieved and understand the script a litlle bit.
So in this case, since the objective is very straight-forward and simple.. I dont see why I do have to go for a hard way of achieving it?
Anyway, thank you so much again for your assistance.
Before I go to that solution, I just would like to know.. Is it true that XYplorer alone could not achieve my goal?
Thank you.
But I was wondering.. Since u have proven that XYplorer could read the CameraModel property, why it is so difficult to achieve batch rename?
I've tried many times and many ways playing around with that property("CameraModel") but to no avail. It will always read the first selected file info only
I'm not really good at programming, but I like to do it when I know that it can be achieved and understand the script a litlle bit.
So in this case, since the objective is very straight-forward and simple.. I dont see why I do have to go for a hard way of achieving it?
Anyway, thank you so much again for your assistance.
Before I go to that solution, I just would like to know.. Is it true that XYplorer alone could not achieve my goal?
Thank you.
-
- Site Admin
- Posts: 60357
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: EXIF Info..
Very easy:aimy wrote:Thank you so much stefan.. May God bless you..
But I was wondering.. Since u have proven that XYplorer could read the CameraModel property, why it is so difficult to achieve batch rename?
I've tried many times and many ways playing around with that property("CameraModel") but to no avail. It will always read the first selected file info only
I'm not really good at programming, but I like to do it when I know that it can be achieved and understand the script a litlle bit.
So in this case, since the objective is very straight-forward and simple.. I dont see why I do have to go for a hard way of achieving it?
Anyway, thank you so much again for your assistance.
Before I go to that solution, I just would like to know.. Is it true that XYplorer alone could not achieve my goal?
Thank you.
Code: Select all
WRONG: rename b, "<dateexif yyyymmdd.hhnnss>~*_$CamMod", p, $file;
RIGHT: rename b, '<dateexif yyyymmdd.hhnnss>~*_' . $CamMod, p, $file;
EDIT: Just assuming that this was the problem. I did not really read the whole thread....
FAQ | XY News RSS | XY Twitter
Re: EXIF Info..
Yes, XYplorer can!aimy wrote:But I was wondering.. Since u have proven that XYplorer could read the CameraModel property, why it is so difficult to achieve batch rename?
I have provided you an working script above > http://www.xyplorer.com/xyfc/viewtopic. ... 045#p57045
The only problem i had was that i didn't have an preview how the files would be renamed.
I have set the "p" option but this show the preview for each and every file
instead for all (selected) files.
But if you didn't need the preview just remove this "p" from the command (after you have seen how the script works)
The second issue i mentioned was that the debug dialog appears if i cancel the script.
But that is only an cosmetic issue, just forget this.
The only advantage of an external tool like SIren is the preview bevor renaming.
We can code our own preview with an workaround, but.... using Siren is more nifty IMHO.
You chose.
Have you tested that script? Didn't work it for you? What is still your "problem"?
CU
Re: EXIF Info..
admin wrote:Finally you come to save us..aimy wrote:Thank you so much stefan.. May God bless you..
But I was wondering.. Since u have proven that XYplorer could read the CameraModel property, why it is so difficult to achieve batch rename?
I've tried many times and many ways playing around with that property("CameraModel") but to no avail. It will always read the first selected file info only
I'm not really good at programming, but I like to do it when I know that it can be achieved and understand the script a litlle bit.
So in this case, since the objective is very straight-forward and simple.. I dont see why I do have to go for a hard way of achieving it?
Anyway, thank you so much again for your assistance.
Before I go to that solution, I just would like to know.. Is it true that XYplorer alone could not achieve my goal?
Thank you.
Thanks a lot admin.
Very easy:The point is that <dateexif yyyymmdd.hhnnss> should only be resolved within rename, not before. Therefore it has to be quoted in single-quotes.Code: Select all
WRONG: rename b, "<dateexif yyyymmdd.hhnnss>~*_$CamMod", p, $file; RIGHT: rename b, '<dateexif yyyymmdd.hhnnss>~*_' . $CamMod, p, $file;
EDIT: Just assuming that this was the problem. I did not really read the whole thread....
Re: EXIF Info..
Stefan, as admin have pointed out, the only mistake in your script is on the rename line.
So, this is the corrected version of your script..
Thanks a lot again for your effort.
Now, there's no more error in the script.. It's just that... As you've mentioned before, this script will preview the renamed files one by one. Just imagine if I need to rename thousand of files and i need them to be previewed all at once. So now, how do I modify the script so that it can preview the renamed files normally just like with this simple rename command..
That's all I need.
Thank you.
So, this is the corrected version of your script..
Code: Select all
$list = get("SelectedItemsPathNames", "|");
$index=1;
while(true)
{
//get one after the other file from file list $file:
$file = gettoken($list, $index, "|");
if ($file==""){break;}
//read property from actual file:
$CamMod = property("CameraModel", $file);
//trim space and tabs around the reported property:
$CamMod = regexreplace($CamMod, "\s*|\t*(.*)\s*|\t*", "$1");
//msg "Debug: #$CamMod#",1;
//rename only if there is no emtpy property:
if ($CamMod != "")
{
rename b, '<dateexif yyyymmdd.hhnnss>~*_' . $CamMod, p, $file;
//rename b, "<dateexif yyyymmdd.hhnnss>~*_$CamMod", $file;
}
//next file:
incr $index;
if ($index > 1000){break;} //prevent infinity loop while script testing
}
Now, there's no more error in the script.. It's just that... As you've mentioned before, this script will preview the renamed files one by one. Just imagine if I need to rename thousand of files and i need them to be previewed all at once. So now, how do I modify the script so that it can preview the renamed files normally just like with this simple rename command..
Code: Select all
rename, '<dateexif yyyymmdd.hhnnss>~*', p;
Thank you.
Re: EXIF Info..
Ahh, OK. Fine. Thanks Don for the help!aimy wrote:Stefan, as admin have pointed out, the only mistake in your script is on the rename line.
So, this is the corrected version of your script..
[...]
Now, there's no more error in the script.. It's just that...
OK once more. Slowly...As you've mentioned before, this script will preview the renamed files one by one. Just imagine if I need to rename thousand of files and i need them to be previewed all at once. So now, how do I modify the script so that it can preview the renamed files normally just like with this simple rename command..
The "p" char in that command
rename b, '<dateexif yyyymmdd.hhnnss>~*_' . $CamMod, p, $file;
is the option to enable that preview dialog.
What is "normally"?
Since we have to work on file by file to get the property for each single file
this rename command is invoked for each file,and so that preview is shown for each file too.
I don't know how to show an preview for all files from an script.
(Only with an workaround and collect all renaming strings and provide
them before real renaming with text() command or like that.)
To get rid of that preview for every file all you have to do is
to remove this p (leave the coma-delimiter) from that command,
as the commented line shows you:
Code: Select all
rename b, '<dateexif yyyymmdd.hhnnss>~*_' . $CamMod, p, $file;
//rename b, '<dateexif yyyymmdd.hhnnss>~*_' . $CamMod", , $file;
and remove the comment signs "//" from the remaining line.
Then you get no preview window anymore.
And BTW, an second pitfall in my script is the debug line to end the script after 1000 files.
You can just remove this whole line if you are sure the script works for your case:
Code: Select all
if ($index > 1000){break;} //prevent infinity loop while script testing
Here as an support is the whole script without those mentioned error handling lines:
Code: Select all
$list = get("SelectedItemsPathNames", "|");
$index=1;
while(true)
{
//get one after the other file from file list $file:
$file = gettoken($list, $index, "|");
if ($file==""){break;}
//read property from actual file:
$CamMod = property("CameraModel", $file);
//trim space and tabs around the reported property:
$CamMod = regexreplace($CamMod, "\s*|\t*(.*)\s*|\t*", "$1");
//rename only if that property is not empty :
if ($CamMod != "")
{
rename b, '<dateexif yyyymmdd.hhnnss>~*_' . $CamMod, , $file;
}
//process next file:
incr $index;
}
Hope this makes it somehow clearer
If anyone have more question(s)... just ask!
Last edited by Stefan on 11 Feb 2011 21:10, edited 1 time in total.
-
- Site Admin
- Posts: 60357
- Joined: 22 May 2004 16:48
- Location: Win8.1 @100%, Win10 @100%
- Contact:
Re: EXIF Info..
No, the comma has to stay:Stefan wrote:To get rid of that preview for every file all you have to do is
to remove this p include the coma-delimiter from that command,
as the commented line shows you:Just delete the line with the pCode: Select all
rename b, '<dateexif yyyymmdd.hhnnss>~*_' . $CamMod, p, $file; //rename b, "<dateexif yyyymmdd.hhnnss>~*_$CamMod", $file;
and remove the comment signs "//" from the remaining line.
Then you get no preview window anymore.
Code: Select all
rename b, '<dateexif yyyymmdd.hhnnss>~*_' . $CamMod, , $file;
FAQ | XY News RSS | XY Twitter