Page 1 of 2
selectitems usage for looping through the selected filelist
Posted: 03 Jan 2012 13:45
by scribbly
I'm just trialing XYplorer after using the free version what seems like years ago.
Current problem is I'm working with photos with EXIF data, but XYplorer does not support EXIF data in the listview (which is a big shame). Anyway, I'm editing my photos that I've copied to a working area, but I need to sort them based on Original Creation Date.
I found others' efforts here in getting a work-around, which is acceptable: ie to copy the EXIF OriginalCreationDate into the Created Date using the
<dateexif> function.
Now my problem is with processing whole folders. I've got the following script in the Catalogue area, but the
selectitems function does not seem to function as expected? What happens if I have many selected is that only the OriginalCreationDate of the first file is used for all the others: I would have expected that selecteditems would select the next as if by the mouse... but that does not seem to be the case??
Code: Select all
$a = get("SelectedItemsPathNames", "|");
foreach($item,$a,"|") {
if($item == "") {break; }
selectitems $item , 0 , 0;
timestamp m c , <dateexif> , $item;
}
Any ideas?
Re: selectitems usage for looping through the selected filel
Posted: 03 Jan 2012 14:32
by admin
Hi and welcome,
this command is already available as a No-GUI command here: CKS / Miscellaneous / Timestamp / Set Created Date to EXIF Date
If you need further support in this, say so.
Don
Re: selectitems usage for looping through the selected filel
Posted: 03 Jan 2012 15:04
by scribbly
admin wrote:Hi and welcome,
this command is already available as a No-GUI command here: CKS / Miscellaneous / Timestamp / Set Created Date to EXIF Date
If you need further support in this, say so.
Thanks... that was easy!!
Just to satisfy my curiosity: why didn't the selectitems function in the script work like I thought?
and to satisfy yet to be realised needs: are there plans to support EXIF metadata in the interface?
Re: selectitems usage for looping through the selected filel
Posted: 03 Jan 2012 15:06
by admin
scribbly wrote:admin wrote:Hi and welcome,
this command is already available as a No-GUI command here: CKS / Miscellaneous / Timestamp / Set Created Date to EXIF Date
If you need further support in this, say so.
Thanks... that was easy!!
Just to satisfy my curiosity: why didn't the selectitems function in the script work like I thought?
and to satisfy yet to be realised needs: are there plans to support EXIF metadata in the interface?
1. No time to check.
2. Yes.

Re: selectitems usage for looping through the selected filel
Posted: 03 Jan 2012 15:24
by TheQwerty
scribbly wrote:Just to satisfy my curiosity: why didn't the selectitems function in the script work like I thought?
Code: Select all
$a = get("SelectedItemsPathNames", "|");
foreach($item,$a,"|") {
if($item == "") {break; }
selectitems $item , 0 , 0;
timestamp m c , <dateexif> , $item;
}
This doesn't work as you expected because "<dateexif>" returns the value for the currently
selected AND
focused list item, and when you change the selection with "selectitems" you're using "0" for the "focusfirst" argument which tells XY to not move the focus.
There's a few ways to fix this:
- Change the focus & selection with selectitems:
Code: Select all
// Replace
selectitems $item, 0, 0;
// with
selectitems $item, 0, 1;
- Instead of using "selectitems" and "<dateexif>" you could retrieve the EXIF data using:
Code: Select all
Property("WhenTaken", $item); //Correct property name depends on OS & Language
This is nice because you can use it without changing the current selection/focus, but I'm not 100% sure if this will give you a date format that can be used by "timestamp" directly. - EDIT: You could also take a more complex approach and instead of using Get("SelectedItemPathNames") to retrieve the current selection - use Report("{Fullpath}|{WhenTaken}<crlf>", 1); to retrieve both the paths and the EXIF data at once, and loop over the lines and use GetToken for the fields. However, according to the help this may not work after XP.
If you've got more questions feel free to ask!

Re: selectitems usage for looping through the selected filel
Posted: 03 Jan 2012 15:36
by scribbly
TheQwerty wrote:
This doesn't work as you expected because "<dateexif>" returns the value for the currently selected AND focused list item, and when you change the selection with "selectitems" you're using "0" for the "focusfirst" argument which tells XY to not move the focus.
Awesome: my misunderstanding of the Help File: "EXIF date of the current list item"
Thanks for the suggestions: definitely helped my understanding
In the end (maybe short term) I used Don's suggestion:
admin wrote:
this command is already available as a No-GUI command here: CKS / Miscellaneous / Timestamp / Set Created Date to EXIF Date
and just changed the script to
which does what I want (and keeps the selection).
Thanks again!
Re: selectitems usage for looping through the selected filel
Posted: 03 Jan 2012 15:39
by admin
scribbly wrote:...and just changed the script to
I admire the tight logic of your scripting.

Re: selectitems usage for looping through the selected filel
Posted: 03 Jan 2012 15:44
by scribbly
admin wrote:scribbly wrote:...and just changed the script to
I admire the tight logic of your scripting.

Well... it was commented too, but I moved the comment to the title to reduce duplication

Re: selectitems usage for looping through the selected filel
Posted: 06 Jan 2012 15:16
by scribbly
admin wrote:scribbly wrote:...and just changed the script to
I admire the tight logic of your scripting.

All is going well... I'm managing to tag my graphics with GPS Exif tags and Date Exif tags based on the original photos, but when I get to writing the Original Date from the Exif DateTimeOrinal I get a requester that I don't really want:
Code: Select all
focus;
END (<curitem>=="", "Select one file to compare with");
$source= <curitem>;
focus pi;
$pane2files = get("SelectedItemsPathNames", "|");
$destination = "";
foreach($token,$pane2files,"|") {
$destination = $destination . quote($token);
}
$items= getinfo ("CountItems");
END ($items==0);
run """C:\Program Files (x86)\ExifTool\exiftool.exe"" -TagsFromFile ""$source"" -GPS:All -DateTimeOriginal -DateTimeDigitized $destination -v2",,1;
#1074; // Set Modified date to DateTimeOriginal
Question: Is there a way to turn off the requester that #1074 pops up?
Re: selectitems usage for looping through the selected filel
Posted: 09 Jan 2012 11:05
by admin
requester? Not sure what you mean.
Re: selectitems usage for looping through the selected filel
Posted: 09 Jan 2012 11:29
by highend
Probably the confirmation window...
Re: selectitems usage for looping through the selected filel
Posted: 09 Jan 2012 11:35
by admin
highend wrote:Probably the confirmation window...
But #1074; has none.
It has a "success" feedback, but this is not meant by "requester" I think.
Re: selectitems usage for looping through the selected filel
Posted: 09 Jan 2012 11:44
by scribbly
admin wrote:highend wrote:Probably the confirmation window...
But #1074; has none.
It has a "success" feedback, but this is not meant by "requester" I think.
Yes.. sorry for the language:
see attached image.
Is there a way to turn this off?
Re: selectitems usage for looping through the selected filel
Posted: 09 Jan 2012 11:47
by admin
Nope, no way I'm afraid. Don't you like the feedback? Where's the problem?
Re: selectitems usage for looping through the selected filel
Posted: 09 Jan 2012 12:01
by scribbly
admin wrote:Nope, no way I'm afraid. Don't you like the feedback? Where's the problem?
Well, I do... and I think it's important too... it's just when you've got a stack of photos to do it's an extra click I would have preferred not to do.
The information also duplicates what I can see in the list: I can see the change happening.
So... not a problem... more a preferrence
