AssetPostprocessor: how to change asset path when importing?

Hi,

I am learning to use the AssetPostprocessor to import assets automatically with specific settings.

So far I am just testing, so I import a model and its textures by selecting the textures folder and the FBX model, then drag and drop onto the “Assets/Models” folder in Unity, I am dragging and dropping the FBX with textures folder because this way the engine automatically assigns the materials and textures.

However the textures folder is imported in the “Models” folder, I would like to change the textures path from “Assets/Models/” to “Assets/Materials/”

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

public class NewBehaviourScript : AssetPostprocessor
{
    void OnPreprocessAsset()
    {
        if (assetImporter.assetPath.EndsWith(".psd"))
        {
            AssetDatabase.ImportAsset(assetImporter.assetPath.Replace("/Models/", "/Materials/"));
        }
    }

}

I have tried this but no luck.
Any help welcome, thanks.

I think the above tells you where it is and that it’s about to do the import. I don’t think you can change paths here

Instead, I think you need to implement this method and do it here:

Caveat: I have not done this type of importation and moving. Good luck!