Failed to rename assets using Python

I’m trying to rename an asset using Python. Here is my code:

import unreal as ue

ar =
ue.AssetRegistryHelpers.get_asset_registry()

ad=
ar.get_asset_by_object_path(‘/Game/Path/To/MyAsset’)

rnd =
ue.AssetRenameData(asset=ad.get_asset(),
new_package_path=‘/Game/Path/To/’,
new_name=‘MyNewAsset’)

rnds = ue.Array(ue.AssetRenameData)

rnds.append(rnd)

at =
ue.AssetToolsHelpers().get_asset_tools()

at.rename_assets(rnds)

Unfortunately, this gives me error:

DataValidation: Error:
/Game/Path/To/MyNewAsset
contains invalid data.

DataValidation: Error: Data validation
FAILED. Files Checked: 1, Passed: 0,
Failed: 1, Skipped: 0, Unable to
validate: 0

But the .uasset file is generated under the physical folder.

What am I missing here?

As far as I know, you should use the file name with the virtual extension of it, so instead of

MyNewAsset

try to use

MyNewAsset.MyNewAsset

Let me know if it works?

Thanks for stepping in. After that, Unreal tells me:

LogPackageName: Error: DoesPackageExist: DoesPackageExist FAILED: ‘MyNewAsset’ is not a standard unreal filename or a long path name. Reason: Path should start with a ‘/’

LogAssetTools: Error: /Game/Path/To/MyAsset - /Game/Path/To/MyAsset.MyAsset to /Game/Path/To/MyNewAsset.MyNewAsset.MyNewAsset.MyNewAsset: Name may not contain the following characters: .

Couldn’t rename ‘MyAssetClass /Game/Path/To/MyAsset.MyAsset’.

Seems that Unreal does not like "periods’ in names.