Return part of file name in Analysis

Goal:

  1. Get a filename in a fixed path (say “C:\prog”), beginning with fixed string (say “myversion_v”
  2. Return the part of the filename starts with “v”

Tried:
names of files whose (name of it starts with “myversion_v”) of folder “C:\prog”

Problems

  1. When I try to use “substring” on it, it fails, because of different object types (set of strings not working with substrings command).
  2. When I try to use “name of first file whose…”, fails, error “first file” not defined.
  3. When I try to define a temporary variable with the command “let”, it seems not working for some reason, but can be that I missed some syntax requirements.

Maybe you will reach the goal from an entirely different approach Keen on hearing/reading.

Thank you anyone/everyone!

Welcome to the forums.

Use this…

names of find files "myversion_*" of folder "c:\prog"

OR this for file checking

if (number of names of find files "myversion_*" of folder "c:\prog" = 0) Then "Not Detected" Else names of find files "myversion_*" of folder "c:\prog"

Possibly @tamaskaracsonyi wants to do this:

(following text of first "_" of it) of names whose (it starts with "myversion_v") of files of folder "C:\prog"
2 Likes

The relevance I put works for us, we use it in an analysis to find all BigFix installers on the netlogon folder.

if (number of names of find files "BigFix*" of folder ((path of it) of network share whose (name of it as string as lowercase = "netlogon" as string as lowercase) & "\patchagent") = 0) Then "Not Detected" Else (names of files whose(name of it as lowercase starts with "BigFix" as lowercase AND name of it ends with ".exe") of folder ((path of it) of network share whose (name of it as string as lowercase = "netlogon" as string as lowercase) & "\patchagent"))

I used this to test for the relevance I put in my first response.

left over from our log4j scans

2 Likes

Thank you itsmpro92, this was the option I started to use, and successfully implemented. Have a great day!

Thank you Dean for extensive help, I have learnt a lot from these code snippets! Have a nice day, cheers!

1 Like