How to eleminate singular expression Singular expression refers to nonexistent object error

(imported topic written by ssriv)

hi,

need help with a query to find out the file version and file description of files in a folder, it is giving error ‘Singular expression refers to nonexistent object’ for the files in which description or version is not present. how can i prevent this error?

q:("File Name: " & name of it,"File Version: " & (version of it as string),"File Description: " & value “FileDescription” of version blocks of it as string) of (descendants of folder “c:\program files\adobe”) whose(name of it as lowercase starts with “photo” as lowercase)

A: File Name: Photoshop.dll, File Version: 7.0.0.0, File Description: Photoshop Resource DLL

A: File Name: Photoshop.exe, File Version: 7.0.0.0, File Description: Adobe Photoshop

A: File Name: Photoshop.fon, File Version: 7.0.0.0, File Description: User Interface Fonts for Adobe Photoshop

E: Singular expression refers to nonexistent object.

q:(descendants of folder “c:\program files\adobe”) whose(name of it as lowercase starts with “photo” as lowercase)

A: “Photoshop.dll” “7.0.0.0” “Photoshop Resource DLL” “7.0” “Adobe Systems, Incorporated”

A: “Photoshop.exe” “7.0.0.0” “Adobe Photoshop” “7.0” “Adobe Systems, Incorporated”

A: “Photoshop.fon” “7.0.0.0” “User Interface Fonts for Adobe Photoshop” “1.0” “Adobe Systems, Incorporated”

A: “Photoshop.reg” “” “” “” “”

A: “Photocopy.8BF” “7.0.0.0” “Photoshop Filter Plugin” “7.0” “Adobe Systems, Incorporated”

A: “Photo CD.8BI” “7.0.0.0” “Photoshop Format Plugin” “7.0” “Adobe Systems, Incorporated”

A: “Photographic Effects.asl” “” “” “” “”

A: “PhotoshopAdapter.apl” “7.0.0.0” “Photoshop Plug-in Adapter” “Version 7.0” “Adobe Systems Incorporated”

(imported comment written by Lee Wei)

The pipe symbol is an OR, so you can try the following.

q: ("File Name: " & (name of it | “None”),"File Version: " & (version of it as string | “None”),"File Description: " & ((value “FileDescription” of version blocks of it as string) | “None”) ) of (descendants of folder “c:\program files\adobe”) whose(name of it as lowercase starts with “photo” as lowercase)

Lee Wei

(imported comment written by ssriv)

it worked.

Thanks a lot.

(imported comment written by jgstew)

It took me a while to figure out how to use the newer pipe ("|") effectively, in which case you can do it the “hard way” with an if / then / else statement for every single option, see this example:

http://bigfix.me/relevance/details/2998470

This is exactly equivalent, but much easier to read:
http://bigfix.me/relevance/details/2998536

(imported comment written by ssriv)

thanks