:DISK:FILE:EXISts?

Query Syntax

:DISK:FILE:EXISts? "filename"

Description

Use this query to test if a file exists. Returns 1 if the file exists and 0 if the file does not exist. To return the size of a file in bytes, use the :DISK:FILE:SIZE? query. To return a time stamp for the file, use the :DISK:FILE:TIMestamp? query.

SCPI commands that perform general file I/O operations are limited to Standard Infiniium File Types and Standard Infiniium Folders.

Example

This Python script (with PyVISA) tests if a specific screen image file exists and returns its size in bytes.

"""
Checks if file exists and returns its size in bytes.
"""
import pyvisa  # PyVISA package

rm = pyvisa.ResourceManager('C:\\WINDOWS\\system32\\visa64.dll')
Infiniium = rm.open_resource("TCPIP0::localhost::hislip0,4880::INSTR")

#Set Timeout - 10 seconds
Infiniium.timeout =  10000
Infiniium.read_termination = '\n'

filePath = '"C:\\Users\\user-name\\Documents\\Keysight\\Infiniium\\Screen Images\\DUT_1.png"'
if Infiniium.query(f':DISK:FILE:EXISts? {filePath}') == '1':
    print('File exists!')
    size = Infiniium.query(f':DISK:FILE:SIZE? {filePath}')
    print(f'File is {size} bytes')
else:
    print('File not found.')
Infiniium.write(':SYSTem:GTLocal')
Infiniium.close()