Get File properties

Discuss and share scripts and script files...
mfu
Posts: 6
Joined: 17 Oct 2012 00:25

Re: Get File properties

Post by mfu »

<<btw, you posted in the wrong post. can you post back in the original place?>>

Oops. Yes. Thx.

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

Re: Get File properties

Post by serendipity »

Moved script to the first page. Might actually be useful to someone. :)

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

Re: Get File properties

Post by TheQwerty »

serendipity wrote:Moved script to the first page. Might actually be useful to someone. :)
It's really not worth it but since you forced this thread to show up in my unread posts view... :P
EDIT: Rather my changes & suggestions may not be worthwhile but the script itself is definitely one everyone should have!

The array usage is a great trick but in this instance I'd suggest using a HEREDOC instead. It could save you at least 116 stepping dialogs and would mean not having to keep count or have a total variable.

Also the Text dialog has a copy button making it easier (and nicer) to just let the user copy the data if they want.

I've taken the liberty of making those changes if you want them - if not I understand.
Properties-v3.xys
My HEREDOC take on a classic.... code below!
(2.75 KiB) Downloaded 290 times

A more challenging task would be to attempt to condense the list to unique property values, listing all of the properties (named or indices) that return the same value. For example:

Code: Select all

2.50 KB = #1
2565 = Size
6/18/2013 12:44 PM = #4, #5
6/18/2013 2:00 PM = #3
6/18/2013 4:44:04 PM = Access, Create
6/18/2013 6:00:52 PM = Write
A = Attrib, Attributes, #6
Properties-v2.xys = Name
XYS File = Type, #2
But that is pretty messy in plaintext without inserting white space, so generating HTML would look better and causes me to lose interest. :lol:


Code: Select all

//Properties-v3 - Gets file properties. 

//This has two parts: 
//Part-1: Uses known property names to get file properties, mostly it will help english users. 
//Part-2: Since its impossible to include property names from all languages, the script simply scans through property IDs 1-500 and get its values.
//Note1: If you want to scan more than 500 then increase the value of WHILE argument in the second part of the script
//Note2: Some values will be redundant as I use two different methods.

//PART-1: Get known property names

  $item = "<curitem>";

  $propertyList = <<<#PROPERTY_LIST
Access
Album
AllocSize
Aperture
Artist
Attrib
Attributes
AttributesDescription
Audio Format
Audio Sample Size
BitDepth
Bitrate
CameraModel
Capacity
Channels
ColorSpace
Company
Compression
Copyright
Create
CSCStatus
Data Rate
DateDeleted
DeletedFrom
Dimensions
Directory
Distance
DocAppName
DocAuthor
DocByteCount
DocCategory
DocCharCount
DocComments
DocCompany
DocCreatedTm
DocEditTime
DocHiddenCount
DocKeywords
DocLastAuthor
DocLastPrinted
DocLastSavedTm
DocLineCount
DocManager
DocNoteCount
DocPageCount
DocParaCount
DocPresentationTarget
DocRevNumber
DocSlideCount
DocSubject
DocTemplate
DocTitle
DocWordCount
DRM Description
Duration
EquipMake
ExposureBias
ExposureProg
ExposureTime
FaxCallerID
FaxCSID
FaxRecipientName
FaxRecipientNumber
FaxRouting
FaxSenderName
FaxTime
FaxTSID
FileDescription
FileSystem
FileType
FileVersion
Flash
FlashEnergy
FNumber
FocalLength
Frame Rate
FrameCount
FreeSpace
Genre
ImageX
ImageY
ISOSpeed
LightSource
LinksUpToDate
LinkTarget
Lyrics
Manager
MeteringMode
MMClipCount
Name
Owner
Play Count
Play Expires
Play Starts
PresentationTarget
ProductName
ProductVersion
Project
Protected
Rank
Rating
ResolutionX
ResolutionY
Sample Rate
Scale
ShutterSpeed
Size
Software
Status
Stream Name
SyncCopyIn
Track
Type
Video Sample Size
WhenTaken
Write
Year
#LinkTarget
#ShortcutTarget
#JunctionTarget
#ResolveJunctions
#ResolveJunctionsAll
#Label
#Tags
#Comment
#HardLinks
#PROPERTY_LIST;

  // Provides a little tolerance and sorting to the property list.
  $propertyList = FormatList($propertyList, 'dents', "<crlf>");
  
  // String building is fun...
  $result = '';

  // Enumerate through all named properties.
  foreach ($key, $propertyList, "<crlf>") {
    if ($key) {
      $value = Property($key, $item);
      if ($value) {
        $result = $result . "$key = $value<crlf>";
      }
    }
  }

  // For: The properties whose names we do not know....
  $i = 0; while ($i <= 500) { $i++;
    $value = Property("#$i", $item);
    if ($value) {
        $result = $result . "#$i = $value<crlf>";
    }
  }


  Text $result;
[/size]

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

Re: Get File properties

Post by serendipity »

TheQwerty wrote:It's really not worth it but since you forced this thread to show up in my unread posts view... :P
EDIT: Rather my changes & suggestions may not be worthwhile but the script itself is definitely one everyone should have!
Thanks! I am basically too lazy to improve any script unless absolutely necessary.
But you are right, Heredoc will save stepping and copy clipboard was redundant since new text window already has the copy button.
Do you mind if I placed this version in the first page for easier access?

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

Re: Get File properties

Post by TheQwerty »

serendipity wrote:Do you mind if I placed this version in the first page for easier access?
Not at all.. you can even claim it as your own and sell it for all I care. ;)

binocular222
Posts: 1416
Joined: 04 Nov 2008 05:35
Location: Hanoi, Vietnam

Re: Get File properties

Post by binocular222 »

@Don: This is definitely better than File > Metadata
Do you intend to update XY's "File > Metadata" ?
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

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 »

"This?" Sorry, but no time to reread a whole ancient thread... :whistle:

But if it is about template driven metadata support, this is already coded and but I never documented it hence you don't know it. :P

CookieMonster

Re: Get File properties

Post by CookieMonster »

admin wrote:"This?" Sorry, but no time to reread a whole ancient thread... :whistle:

But if it is about template driven metadata support, this is already coded and but I never documented it hence you don't know it. :P
The scripts in this thread are useless as it's embedded into XY ?

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Get File properties

Post by highend »

My version of the script...

I personally find the output easier to read and it separates used from unused properties, etc.

The #hash.xxx values are commented out (via a ";" in front of each line). If you want them back, just remove the semicolon for any of them.

Current:
Properties-v5.zip
(1.49 KiB) Downloaded 271 times
Old:
Properties-v4.zip
(1.42 KiB) Downloaded 293 times
One of my scripts helped you out? Please donate via Paypal

FluxTorpedoe
Posts: 855
Joined: 05 Oct 2011 13:15

Re: Get File properties

Post by FluxTorpedoe »

Cool!
That's a script that always came in handy!
Now your version makes it even fancier… ;)

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 »

highend wrote:Current:
Properties-v5.zip
There seems to be a bug in that script (a missing closing parenthesis), here is my fix:

Code: Select all

OLD:      } elseif (regexmatches($propValue, "[^\s]+") {
NEW:      } elseif (regexmatches($propValue, "[^\s]+")) {
I only wonder why nobody noted this for almost 3 years. :veryconfused:

Apart from that: useful script! :tup:

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Get File properties

Post by highend »

I only wonder why nobody noted this for almost 3 years
Good question...

Nonetheless, here is v5.1...
Properties_v5.1.zip
(1.5 KiB) Downloaded 468 times
One of my scripts helped you out? Please donate via Paypal

chasster123
Posts: 21
Joined: 06 Mar 2016 15:54
Location: Texas

Re: Get File properties

Post by chasster123 »

Thanks for a quick response to my seeking all Original files - however, i'm no longer around programmers as a general rule and would appreciate a bit of additional text.
What i'm hoping for is an instruction that might suggest that i drop the script (ref. 5.1) into the scripts folder (or other instruction) so that this tweak will work all the time.

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Get File properties

Post by highend »

This thread contains different methods to execute a script: viewtopic.php?f=7&t=6560

At the end of the thread under: B.) How to execute an script by loading it from an file
One of my scripts helped you out? Please donate via Paypal

Post Reply