[Solved]How to change asset's folder in Editor

Hi,guys,I want to know the correct way to change the path of the asset in Editor,I tried:


but no luck.The asset is back to where it was after refreshing the browser,am I missing some steps?can anyone give me some advice?

Hi @FBplus,

Using the unofficial Playcanvas editor API you can do the following:

   let myFolder = editor.call("assets:findOne", (asset) => {
     return asset.get("type") === "folder" && asset.get("name") === 'Folder Name';

   editor.call("assets:panel:currentFolder", myFolder[1]);

Hi @Leonidas,Thanks for your reply :smiley: ,but the main purpose I want to achieve is moving the specific assets to another folder,the code above is just select one folder in editor if I am not wrong :thinking:

I think then you need to change the parent property for each asset. I haven’t tried it but something like this may work:

var asset = editor.call("assets:get",assetId);
asset.set('parent', myFolder[1]);
1 Like

@Leonidas It seems it’s not right,I will do more research about it,thanks :grinning:

Seems parent works only when you create the asset item in editor.

I got it working using the following structure:

editor.call("assets:get",40131522).set('path', [ myFolder[1].get('id') ]);

@Leonidas Yes,but after refreshing the browser,the asset is back to where it was,do you have this same issue?

Yes, I get the same result, not sure why, most likely the array we are passing isn’t correct. @vaios may be able to be of help on this :innocent:

1 Like

You can also try and step through the editor.js code with debugger and see what happens when you move an asset using drag and drop in editor. To see what exact methods are being called.

1 Like


I do not recommend you use these functions because they are likely to change without notice. BUT I believe the current way to do this is:
editor.call('assets:fs:move', assets, folderAsset);


Do not modify path value of the asset, as it might lead to unwanted results, as asset might be “out” of filesystem. It will still exist and be accessible through list, as all assets stored in flat maner.
In order to make any filesystem operations, such as moving assets (those are files and folders), or deleting them, you should use methods as @vaios mentioned:

To move assets to root directory, use null instead of folderAsset.

To delete assets, you should use:

editor.call('assets:fs:delete', assets);