Safe Deletion
Safe Deletion ensures you don't accidentally break your project by deleting assets or folders that are still referenced elsewhere.
Overview
The Safe Delete feature:
- ✅ Scans for external references before deleting
- ✅ Warns if deletion would break references
- ✅ Only deletes if safe (no external referencers)
- ✅ Cleans up empty parent folders automatically
- ✅ Fixes redirectors after deletion
How It Works
graph TD
A[Select Folder] --> B[Scan Dependencies]
B --> C{Has External<br/>Referencers?}
C -->|Yes| D[Show Warning]
D --> E[Cancel Delete]
C -->|No| F[Confirm Delete]
F --> G{User<br/>Confirms?}
G -->|No| E
G -->|Yes| H[Delete Assets]
H --> I[Delete Empty Folders]
I --> J[Fix Redirectors]
J --> K[Complete]
Features
Dependency Checking
Before deletion, the system:
- Scans all assets in the folder
- Finds all referencers (what uses these assets)
- Separates internal vs external references
- Determines if deletion is safe
Safe to delete:
- No external references
- Only internal references (within same folder)
- No dependencies outside the folder
Not safe to delete:
- Has external referencers (assets in other folders use it)
- Would break references in Blueprints, Materials, etc.
- Required by maps or other critical assets
Warning System
If deletion is unsafe:
❌ Cannot safely delete this folder
The following assets have external references:
• BP_Character (referenced by 3 Blueprints)
• M_Material (used in 5 Maps)
• T_Texture (referenced by 12 Materials)
Deleting would break these references.
Empty Folder Cleanup
After successful deletion:
- Check parent folders
- Delete any empty folders
- Recurse up the folder tree
- Stop when a non-empty folder is found
Redirector Management
After deletion:
- Fix any broken redirectors
- Update redirector paths
- Clean up redirector chains
Usage
From Content Browser
- Right-click a folder
- Select Elys Asset Tools → Safe Delete Folder
- Review the dependency scan results
- Confirm deletion if safe
- Cancellation if unsafe
Via Blueprint
// Get subsystem
UERP_AssetToolsEditorSubsystem* Subsystem =
GEditor->GetEditorSubsystem<UERP_AssetToolsEditorSubsystem>();
// Check if safe first
bool bSafe = Subsystem->IsFolderSafeToDelete("/Game/ToDelete");
if (bSafe)
{
// Proceed with deletion
bool bDeleted = Subsystem->SafeDeleteFolder("/Game/ToDelete");
}
else
{
UE_LOG(LogElysAssetTools, Warning, TEXT("Folder has external references!"));
}
Via C++
// Check safety
FERP_AssetDependencyScanResult ScanResult = Subsystem->ScanFolder("/Game/ToDelete");
// Count external referencers
int32 ExternalRefs = 0;
for (const FAssetData& Referencer : ScanResult.Referencers)
{
if (!Referencer.PackagePath.ToString().StartsWith("/Game/ToDelete"))
{
ExternalRefs++;
}
}
if (ExternalRefs == 0)
{
// Safe to delete
FAssetRegistryModule& AssetRegistry = FModuleManager::LoadModuleChecked<FAssetRegistryModule>("AssetRegistry");
// ... perform deletion
}
Safety Rules
What Makes a Folder Safe to Delete?
A folder is safe to delete if ALL of these are true:
- No external assets reference assets in this folder
- All dependencies are either:
- Within the same folder (internal)
- Engine content
- Plugin content (not being deleted)
- No assets in this folder are:
- Currently open in an editor
- Loaded in memory by a running game
- Part of a C++ class
What's Considered an External Reference?
External references:
- Blueprints in other folders
- Materials in other folders
- Maps that include these assets
- Data assets that reference these assets
NOT external references:
- References within the same folder
- Engine content references (always available)
- Plugin content references (assuming plugins stay)
Best Practices
Before Deleting
- Run dependency scan - Understand what you're deleting
- Check referencers - Know what would be affected
- Commit to version control - Have a backup
- Consider moving instead - Deletion is permanent
Alternative: Move to Archive
Instead of deleting, consider:
// Move to archive folder instead of deleting
Subsystem->StartMoveAssets({"/Game/ToDelete"}, "/Game/Archive/Deleted");
This way:
- Content is preserved
- References still work
- Can be recovered if needed
- Can delete archive periodically
Verifying Safety Manually
// Get detailed dependency info
FERP_AssetDependencyScanResult Result = Subsystem->ScanFolder("/Game/MyFolder");
// Log all external referencers
for (const FAssetData& Referencer : Result.Referencers)
{
FString PackagePath = Referencer.PackagePath.ToString();
if (!PackagePath.StartsWith("/Game/MyFolder"))
{
UE_LOG(LogElysAssetTools, Warning, TEXT("External referencer: %s"), *Referencer.AssetName.ToString());
}
}
Delete Empty Folders
Separate feature for cleaning up empty folders:
From Content Browser
- Right-click a folder
- Select Elys Asset Tools → Delete Empty Folders
- Scans recursively for empty folders
- Deletes all empty subfolders
What's Considered Empty?
A folder is empty if it contains:
- No assets
- No subfolders with assets
- Only redirectors (optionally)
Via Blueprint
// Delete all empty folders under a path
Subsystem->DeleteEmptyFolders("/Game/Content");
Via C++
// Recursively find and delete empty folders
void DeleteEmptyFoldersRecursive(const FString& BasePath)
{
IAssetRegistry& AssetRegistry = FModuleManager::LoadModuleChecked<FAssetRegistryModule>("AssetRegistry").Get();
TArray<FString> SubPaths;
AssetRegistry.GetSubPaths(BasePath, SubPaths, false);
for (const FString& SubPath : SubPaths)
{
// Recurse first
DeleteEmptyFoldersRecursive(SubPath);
// Check if now empty
TArray<FAssetData> Assets;
AssetRegistry.GetAssetsByPath(*SubPath, Assets, false);
if (Assets.Num() == 0)
{
// Delete folder (UE Editor function)
IFileManager::Get().DeleteDirectory(*SubPath, false, true);
}
}
}
Troubleshooting
"Cannot delete - has references" but folder appears unused
Possible causes:
- Soft references - Check for soft object references
- Redirectors - Old redirectors may still point here
- C++ references - Native code may reference these assets
- Recently moved - Asset Registry may not be updated
Solutions:
// Force refresh Asset Registry
FAssetRegistryModule::AssetCreated(Asset);
FAssetRegistryModule::AssetDeleted(Asset);
Deletion succeeds but references break
This shouldn't happen with Safe Delete, but if it does:
- Use Undo (Ctrl+Z) immediately
- Restore from version control
- Re-import deleted assets
- Fix up redirectors
Cannot delete specific asset
If a single asset blocks deletion:
- Find what references it (use Dependency Scanner)
- Remove those references first
- Or move the problematic asset elsewhere
- Then delete the folder
API Reference
See Subsystem API for complete API documentation.
Next Steps
- Dependency Scanner - Understand what you're deleting
- Folder Management - Clean up empty folders
- User Guide: Cleaning Up - Step-by-step tutorial