# :DISK:FILE:SIZE?

:DISK File Transfer Commands

- :DISK:FILE:ASCii:READ?
- :DISK:FILE:EXISts?
- :DISK:FILE:READ?
- :DISK:FILE:SIZE?
- :DISK:FILE:TIMestamp?
- :DISK:FILE:WRITe?

## Query Syntax

    :DISK:FILE:SIZE? "filename"

## Description

Returns the size of a file in bytes. To determine if a file exists, use the `:DISK:FILE:EXISts?` query. If file does not exists, 0 is returned. 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

    rm = pyvisa.ResourceManager("C:\\Windows\\System32\\visa64.dll")
    Infiniium = rm.open_resource("TCPIP0::localhost::hislip0::INSTR")

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

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