This site requires JavaScript to be enabled
IE BUMPER

Tosca Version
IncidentLookup using list
Language
How can we help?

Solution Suggestions

Please enter your question to get suggestions.
  Help
IE BUMPER
Product
Results per page
Tosca Version
Categories
Version
Boolean Operators
OR or vertical bar symbol (|)
Finds a match if either the terms exist in a document (a union using sets).
AND
Finds a match if both terms exist in a document (an intersection of sets).
NOT, minus (-), or exclamation point (!)
Excludes documents that contain the term after NOT (a difference of sets).
Wildcards
Asterisk (*)
The asterisk symbol performs a multi character wildcard search.
Percent sign (%)
The percent sign performs a single character wildcard search.
Phrases
Quotation marks (")
Use quotation marks to search for an exact phrase with multiple terms.
For examples and more information look at our Knowledge Base: Advanced Search On The Support Portal

Handling files with dynamic names

This article describes how to get all the filenames, latest downloaded/modified filenames, filenames with particular extensions, filenames with some static part, filenames depending on their size from a directory.


Situation AND Solution

Situation 1
There can be a scenario where you want to buffer the name of the latest downloaded/modified filename from a folder.This will be mainly helpful where you have a situation to check an existence, read the contents of a file or to delete a file using Standard File Operations modules.

 

Solution 1
You can buffer latest downloaded/modified filename from a folder using powershell command "(Get-ChildItem | Sort-Object LastAccessTime -Descending | Select-Object -First 1).Name | Clip". You will need to use TBox Start Program module to launch the powershell and run the command. The mentioned command gets all the files in a directory, sorts them in descending order of time and selects the most recent file. The | Clip syntax is used to copy the result into the clipboard. After that you can use TBox Clipboard module to buffer the filename from clipboard. In below example the filename will be saved in the buffer named NewestFile.

 

Note: The above explained command can be modified a bit to fetch the last few records as per the requirement.

For example: If you want to buffer the 3 latest downloaded/modified filenames from folder use the command "(Get-ChildItem | Sort-Object LastAccessTime -Descending | Select-Object -First 3).Name | Clip"

 

Situation 2
There can be a situation where you have a filename which always has some static part in it and some dynamic part and you want to buffer this filename depending on its static part. This is mostly helpful when few files are generated at the same time, so these files can't be sorted based on their date and time. 

 

Solution 2
For eg. you have a file named File123.txt in your folder. File and .txt is static part in it, 123 is the dynamic part. To buffer this filename, first use the powershell command "Get-ChildItem | Clip" to fetch all the files in the directory and after that you will have you use a regular expression  {REGEX["New(?<filename>[\d ]*).txt"]}  to buffer the dynamic part of filename depending on its static part. Finally, you can buffer the entire filename using TBox Set Buffer.

Note: The regular expression will always change depending on the requirement. For more information on how to extract the dynamic part of a string using regular expressions, please refer to: https://support.tricentis.com/community/manuals_detail.do?lang=en&version=11.0.0&url=tbox/regular_expressions.htm

 

Situation 3
When you want to buffer names of all files with a specific extension (e.g. all files with extension .txt. .docx,.pdf ... etc.)

Solution 3
Use powershell command : "Get-ChildItem *.txt | Clip"


Note: 1) When you want to buffer the names of all the files at a particular location, use the command: "Get-ChildItem| Clip"

            2) When you want to buffer the names of all the files larger than 50 KB, use the below powershell command:

               "Get-ChildItem | Where-Object {$_.Length -gt 50KB}| Clip"

 

[opt.] Reference

https://www.pdq.com/blog/using-get-childitem-find-files/

 

0 0

Chiranjibi Behera

Created: 2018-08-16 14:21:40

Hi Diksha Dumbre,

This article is really a helping one to most people.

I have a scenario related to this article with some variation as mentioned below. Could you please help me on it.

Need to copy the latest modified of a particular csv file (as there are so many files with same name) and paste it in another folder.

Thanks,

Chiranjibi

1 0

Lavanya Chetti

Created: 2018-09-07 21:29:35

Diksha,

Your article was so helpful for my scenario where i had to get the full .csv filename. Thank you so much for the effort.

Thanks

Lavanya

 

IE BUMPER

Tosca is the perfect solution

Optimize - Manage - Automate

Download Trial