Page 1 of 2

Get File properties

Posted: 30 Dec 2011 19:10
by serendipity
UPDATE:
Essentially the same code posted here -> http://www.xyplorer.com/xyfc/viewtopic. ... 562#p71562
Just moving it to the first post for better visibility.

What it does:
The script goes through file's properties and reports it back in a text format.

How it does:
Makes use of the XY scripting command property()
In the first pass the script goes through all the known property names such as artist, album etc.
In the second pass it goes through the ID numbers of the properties, from #1-#500 to give you a list of available properties.

Usage:
Download the below file, place it in XY's scripts folder, select the file you want to find the info about and run the downloaded script from XY's menu "Scripting | Load script file" and select "Properties-v2.xys".
Properties-v2.xys
(3.53 KiB) Downloaded 650 times
Some notes:
1. You also run the script from several other places including address bar, simple paste this and hit enter: ::load "Properties-v2.xys";
2. Some properties might be reported twice because the script uses two different methods and hence overlap.
3. You can use the reported properties in your own script.
For example #1 always reports file size so you can select a file and use this command from address bar to get file size info:

Code: Select all

::text property ("#1");
Alternatively, you can use v3 modified by TheQwerty. Essentially does the same thing, just uses HEREDOC instead of arrays:
Properties-v3.xys
(2.75 KiB) Downloaded 621 times
Keeping the first version of the code for those interested.
This script reports properties of a selected file in XY's text box and copies it to clipboard too. Just a convenient way of seeing all properties without right-clicking file etc.
//Check available properties of a file.
$item=<curitem>;
$p1=Access;
$p2=Album;
$p3=AllocSize;
$p4=Aperture;
$p5=Artist;
$p6=Attrib;
$p7=Attributes;
$p8=AttributesDescription;
$p9=Audio Format;
$p10=Audio Sample Size;
$p11=BitDepth;
$p12=Bitrate;
$p13=CameraModel;
$p14=Capacity;
$p15=Channels;
$p16=ColorSpace;
$p17=Company;
$p18=Compression;
$p19=Copyright;
$p20=Create;
$p21=CSCStatus;
$p22=Data Rate;
$p23=DateDeleted;
$p24=DeletedFrom;
$p25=Dimensions;
$p26=Directory;
$p27=Distance;
$p28=DocAppName;
$p29=DocAuthor;
$p30=DocByteCount;
$p31=DocCategory;
$p32=DocCharCount;
$p33=DocComments;
$p34=DocCompany;
$p35=DocCreatedTm;
$p36=DocEditTime;
$p37=DocHiddenCount;
$p38=DocKeywords;
$p39=DocLastAuthor;
$p40=DocLastPrinted;
$p41=DocLastSavedTm;
$p42=DocLineCount;
$p43=DocManager;
$p44=DocNoteCount;
$p45=DocPageCount;
$p46=DocParaCount;
$p47=DocPresentationTarget;
$p48=DocRevNumber;
$p49=DocSlideCount;
$p50=DocSubject;
$p51=DocTemplate;
$p52=DocTitle;
$p53=DocWordCount;
$p54=DRM Description;
$p55=Duration;
$p56=EquipMake;
$p57=ExposureBias;
$p58=ExposureProg;
$p59=ExposureTime;
$p60=FaxCallerID;
$p61=FaxCSID;
$p62=FaxRecipientName;
$p63=FaxRecipientNumber;
$p64=FaxRouting;
$p65=FaxSenderName;
$p66=FaxTime;
$p67=FaxTSID;
$p68=FileDescription;
$p69=FileSystem;
$p70=FileType;
$p71=FileVersion;
$p72=Flash;
$p73=FlashEnergy;
$p74=FNumber;
$p75=FocalLength;
$p76=Frame Rate;
$p77=FrameCount;
$p78=FreeSpace;
$p79=Genre;
$p80=ImageX;
$p81=ImageY;
$p82=ISOSpeed;
$p83=LightSource;
$p84=LinksUpToDate;
$p85=LinkTarget;
$p86=Lyrics;
$p87=Manager;
$p88=MeteringMode;
$p89=MMClipCount;
$p90=Name;
$p91=Owner;
$p92=Play Count;
$p93=Play Expires;
$p94=Play Starts;
$p95=PresentationTarget;
$p96=ProductName;
$p97=ProductVersion;
$p98=Project;
$p99=Protected;
$p100=Rank;
$p101=Rating;
$p102=ResolutionX;
$p103=ResolutionY;
$p104=Sample Rate;
$p105=Scale;
$p106=ShutterSpeed;
$p107=Size;
$p108=Software;
$p109=Status;
$p110=Stream Name;
$p111=SyncCopyIn;
$p112=Track;
$p113=Type;
$p114=Video Sample Size;
$p115=WhenTaken;
$p116=Write;
$p117=Year;

$total=117;
$count=1;
copytext;
//step;

WHILE ($count < 118) {
$property= eval($p$count);
$prop= property ("$property", "$item");

IF ($prop == "") {
incr $count;
}
ELSE {
copytext ("$property = $prop <crlf>", a);
incr $count;
}
}
$clip= <clipboard>;
status "Properties copied to clipboard";
text $clip;

Re: Get File properties

Posted: 01 Jan 2012 17:20
by admin

Code: Select all

eval($p$count)
WOW, you "discovered" "arrays"!

Re: Get File properties

Posted: 01 Jan 2012 18:20
by serendipity
admin wrote:

Code: Select all

eval($p$count)
WOW, you "discovered" "arrays"!
Really! I've been using this for a long time. You mean you never allowed it or you allowed it but no one discovered it?

Re: Get File properties

Posted: 01 Jan 2012 18:55
by admin
serendipity wrote:
admin wrote:

Code: Select all

eval($p$count)
WOW, you "discovered" "arrays"!
Really! I've been using this for a long time. You mean you never allowed it or you allowed it but no one discovered it?
No, it never crossed my mind to do this radical thing. It's very dirty, but it works. :)

Re: Get File properties

Posted: 01 Jan 2012 19:36
by serendipity
admin wrote:
serendipity wrote:
admin wrote:

Code: Select all

eval($p$count)
WOW, you "discovered" "arrays"!
Really! I've been using this for a long time. You mean you never allowed it or you allowed it but no one discovered it?
No, it never crossed my mind to do this radical thing. It's very dirty, but it works. :)
Oh, i thought your intention to provide "eval" was to do such things, so I never questioned it.
You provide and we use it in every dirty way possible. If it doesn't work we come back to ask more. And the cycle continues.

Re: Get File properties

Posted: 20 Feb 2012 16:21
by tiago
guys, what's the smartest way to get a file or list of files' date of creation?
report() only works on current visible file list and that's a limiter.

Re: Get File properties

Posted: 20 Feb 2012 16:26
by TheQwerty
tiago wrote:guys, what's the smartest way to get a file or list of files' date of creation?
report() only works on current visible file list and that's a limiter.
You can pass report an item list:

Code: Select all

text report("{FullName} - {Created}<crlf>", 'C:\windows\notepad.exe|C:\windows\system32\calc.exe');

Re: Get File properties

Posted: 20 Feb 2012 16:48
by tiago
That'll do. Thank you very much!

Re: Get File properties

Posted: 10 Mar 2012 23:01
by Filehero
admin wrote:

Code: Select all

eval($p$count)
WOW, you "discovered" "arrays"!
I've not completely got it yet. To me, it rather looks like a lookup in a Dictionary/Map. :?:


Cheers,
Filehero

Re: Get File properties

Posted: 10 Mar 2012 23:21
by RalphM

Code: Select all

eval($p$count)
But this dictionary as you call it is two-dimensional, so it's an array, since $p denotes the first and $count the second dimension of an array...

Re: Get File properties

Posted: 11 Mar 2012 00:05
by Filehero
Hi RalphM,
RalphM wrote:

Code: Select all

eval($p$count)
But this dictionary as you call it is two-dimensional, so it's an array, since $p denotes the first and $count the second dimension of an array...
I know, that most if not all Map/Dictionay-implementations are based on two-dimensional arrays (1st dimension: key, 2nd dimension: value), I've even written one by myself. :wink:

But you're right, my question was somewhat imprecise. So, I'll give it another try.

From the original post and Don's reply ("arrays") I first thought he really means plain vanilla one-dimensional arrays. But soon I wondered if the counter of the while-loop really could provide the index the script-engine uses to access the value, and

Code: Select all

eval($p$count);
will be translated to an index-based array access like

Code: Select all

Pseudocode:
return array$p[$count];
But this does not make much/any sense (could be done, but I can't think of any clumsier way..).

So, I guess in the script runtime context it really works like

Code: Select all

Pseudocode:
return mapScriptVariables.get("$p$count");
where the script variable names are just keys in a Dictionary. And this is what your answer implies. :D

Well, the hidden agenda of my question is: I'd love to see direct array and map support in XYscript. :wink:


Cheers,
Filehero

Re: Get File properties

Posted: 11 Mar 2012 17:54
by admin
Arrays are not totally impossible. One day...

Re: Get File properties

Posted: 26 Mar 2012 20:41
by serendipity
Update:
Moved the script to first page for better visibility. Please download script from here -> http://www.xyplorer.com/xyfc/viewtopic. ... 261#p67261

Properties-v2
Included another method to scan properties. It simply scans through #1-#500 to get properties. Might be useful for non-English users.
[attachment=0]Properties-v2.xys[/attachment]

Re: Get File properties

Posted: 17 Oct 2012 21:07
by mfu
Checked list under Configuration | File Info Tips | Show custom file info tips. Title, Subject, Tags are on list. Selected.

Added some Word docs to datafolder and ran script. Worked for doc files. Placement not at end of original filiename, and used same (Title, Subject, Tags) value for all files. But kinda worked.

I want to use on CAD files (solidworks 2012), on Win7 64bit OS.

Ran viewtopic.php?p=71562#p71562 on solidworks files and it did not return an index for Title, Subject, Tags for solidworks files.

Any other suggestions? I will check with Solidworks to see if they have something.

Thanks

Re: Get File properties

Posted: 17 Oct 2012 21:28
by serendipity
mfu wrote:Checked list under Configuration | File Info Tips | Show custom file info tips. Title, Subject, Tags are on list. Selected.

Added some Word docs to datafolder and ran script. Worked for doc files. Placement not at end of original filiename, and used same (Title, Subject, Tags) value for all files. But kinda worked.

I want to use on CAD files (solidworks 2012), on Win7 64bit OS.

Ran viewtopic.php?p=71562#p71562 on solidworks files and it did not return an index for Title, Subject, Tags for solidworks files.

Any other suggestions? I will check with Solidworks to see if they have something.

Thanks
On those CAD files, did you check all the indices? maybe they are mapped to other #.
Also, i guess you checked File>Properties>Details and the files have title, subject etc?
Also, if the file is small maybe you can attach it here?
btw, you posted in the wrong post. can you post back in the original place?