NameWithoutExtension Property

Applies to TestComplete 15.69, last modified on November 13, 2024

Description

The NameWithoutExtension property holds the name (without the path and extension) of the file specified by the aqFileInfoObj object.

Declaration

aqFileInfoObj.NameWithoutExtension

Read-Only Property String
aqFileInfoObj An expression, variable or parameter that specifies a reference to an aqFileInfo object

Applies To

The property is applied to the following object:

Property Value

A string containing the file name without the extension.

Example

The code below obtains the collection of all the files located in the specified folder and then posts the files' names without extensions to the test log.

JavaScript, JScript

function FileNameExample()
{
 // Sets the path to the desired folder
 FolPath = "C:\\MyFiles";
 
 // Gets the total number of the files located in the folder
 var FilesNum = aqFileSystem.GetFolderInfo(FolPath).Files.Count;
 
 var FileItems = aqFileSystem.GetFolderInfo(FolPath).Files;
 
 // Posts the names of all the files located in the folder to the test log
 for (var i = 0; i<FilesNum; i++)
  Log.Message(FileItems.Item(i).NameWithoutExtension)
 
}

Python

def FileNameExample():
  # Sets the path to the desired folder
  FolPath = "C:\\MyFiles"
  # Gets the total number of the files located in the folder 
  FilesNum = aqFileSystem.GetFolderInfo(FolPath).Files.Count
  FileItems = aqFileSystem.GetFolderInfo(FolPath).Files
  # Posts the names of all the files located in the folder to the test log
  for i in range(0, FilesNum):
    Log.Message(FileItems.Item(i).NameWithoutExtension)

VBScript

Sub FileNameExample

 ' Sets the path to the desired folder
 FolPath = "C:\MyFiles"
 
 ' Gets the total number of the files located in the folder
 FilesNum = aqFileSystem.GetFolderInfo(FolPath).Files.Count
 
 Set FileItems = aqFileSystem.GetFolderInfo(FolPath).Files
 
 ' Posts the names of all the files located in the folder to the test log
 For i = 0 to FilesNum-1
  Call Log.Message(FileItems.Item(i).NameWithoutExtension)
 Next
 
End Sub

DelphiScript

function FileNameExample;
var FolPath, FilesNum, FileItems, i;
begin

 // Sets the path to the desired folder
 FolPath := 'C:\MyFiles';
 
 // Gets the total number of the files located in the folder
 FilesNum := aqFileSystem.GetFolderInfo(FolPath).Files.Count;
 
 FileItems := aqFileSystem.GetFolderInfo(FolPath).Files;
 
 // Posts the names of all the files located in the folder to the test log
 For i := 0 to (FilesNum - 1) do
  Log.Message(FileItems.Item(i).NameWithoutExtension);
 
end;

C++Script, C#Script

function FileNameExample()
{

 // Sets the path to the desired folder
 FolPath = "C:\\MyFiles";
 
 // Gets the total number of the files located in the folder
 var FilesNum = aqFileSystem["GetFolderInfo"](FolPath)["Files"]["Count"];
 
 var FileItems = aqFileSystem["GetFolderInfo"](FolPath)["Files"];
 
 // Posts the names of all the files located in the folder to the test log
 for (var i = 0; i<FilesNum; i++)
  Log["Message"]( FileItems["Item"](i)["NameWithoutExtension"] )
 
}

See Also

Working With Files From Scripts
GetFileInfo Method
FindFiles Method
Name Property
Path Property
Drive Property

Highlight search results