Skip to main content
Version: v2

renameSync

Start from API_LEVEL 2.0 . Please refer to API_LEVEL.

Rename the files in the /data directory of the Mini Program, renaming the files from oldPath to newPath.

Type​

function renameSync(option: Option): Result

Parameters​

Option​

PropertyTypeRequiredDefaultValueDescriptionAPI_LEVEL
oldPathstringY-Old path2.0
newPathstringY-New path2.0

Result​

TypeDescription
numberIf 0 is returned, success is indicated

Example​

import { renameSync } from '@zos/fs'

const result = renameSync({
oldPath: 'test.txt',
newPath: 'new_test.txt',
})

if (result === 0) {
console.log('renameSync success')
}