Get File properties

Discuss and share scripts and script files...
serendipity
Posts: 3358
Joined: 07 May 2007 18:14
Location: NJ/NY

Get File properties

Post 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 649 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 617 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;
Last edited by serendipity on 20 Jun 2013 04:49, edited 3 times in total.

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Get File properties

Post by admin »

Code: Select all

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

serendipity
Posts: 3358
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Get File properties

Post 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?

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Get File properties

Post 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. :)

serendipity
Posts: 3358
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Get File properties

Post 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.

tiago
Posts: 589
Joined: 14 Feb 2011 21:41

Re: Get File properties

Post 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.
Power-hungry user!!!

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Get File properties

Post 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');

tiago
Posts: 589
Joined: 14 Feb 2011 21:41

Re: Get File properties

Post by tiago »

That'll do. Thank you very much!
Power-hungry user!!!

Filehero
Posts: 2644
Joined: 27 Feb 2012 18:50
Location: Windows 10 Pro x64

Re: Get File properties

Post 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

RalphM
Posts: 1932
Joined: 27 Jan 2005 23:38
Location: Cairns, Australia

Re: Get File properties

Post 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...
Ralph :)
(OS: W11 22H2 Home x64 - XY: Current beta - Office 2019 32-bit - Display: 1920x1080 @ 125%)

Filehero
Posts: 2644
Joined: 27 Feb 2012 18:50
Location: Windows 10 Pro x64

Re: Get File properties

Post 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

admin
Site Admin
Posts: 60357
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Get File properties

Post by admin »

Arrays are not totally impossible. One day...

serendipity
Posts: 3358
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Get File properties

Post 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]
Attachments
Properties-v2.xys
(3.53 KiB) Downloaded 392 times
Last edited by serendipity on 18 Jun 2013 17:30, edited 1 time in total.

mfu
Posts: 6
Joined: 17 Oct 2012 00:25

Re: Get File properties

Post 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

serendipity
Posts: 3358
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Get File properties

Post 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?

Post Reply