Rename or change the location of a file (There is dependence of the system of used files in the change of location).

1 file.renameTo

<file.renameTo>
    <file /> !
    <name /> !
</file.renameTo>

Exceptions

requires 2 arguments, received: [...]

It has not been specified correctly the number of argument.

bad type - expected [file] while found [...]

A value which is not a File has been indicated as file.

bad type - expected [string] while found [...]

A value which is not a String has been informed as file name.

Example

Rename the name of a file.

Copy
<xsql-script name='file_renameTo_sample1'>
    <body>
        <set name='m_oldname'>
            <string>c:<file.separator />tmp<file.separator />data.txt</string>
        </set>
        <set name='m_newname'>
            <string>c:<file.separator />tmp<file.separator />datos.dat</string>
        </set>
        <println>Current name of the file: <m_oldname/></println>
        <println>New name of the file: <m_newname/></println>
        <set name='m_result'>
            <file.renameTo>
                <file name='#m_oldname' type='absolute' />
                <m_newname/>
            </file.renameTo>
        </set>
        <if>
            <expr>
                <eq>
                    <m_result/>
                    1
                </eq>
            </expr>
            <then>
                <set name='m_word'>success</set>
            </then>
            <else>
                <set name='m_word'>failure</set>
            </else>
        </if>
        <println>Result of the renamed : <m_word/></println>
    </body>
</xsql-script>