How to Use
This Python script removes metadata from .safetensors files (commonly used for LoRAs, embeddings, and other Stable Diffusion / AI model files) and saves clean copies to a separate folder. It is especially useful for cleaning LoRAs before sharing them or rename them (just rename the original .safetensors file and run the script).
1. Prerequisites
Python 3.8 or higher installed.
The safetensors library installed.
Install the required package (run in your terminal / command prompt):
Bash
pip install safetensors torchNote: You only need torch if it's not already installed, safetensors is the main dependency.
2. Prepare the Script
Unzip and save the provided script as metadata_remover_and_rename.py (it is already attached in this conversation).
Edit the folder paths at the top of the file.
Open the file in any text editor (Notepad, VS Code, etc.) and update these two lines:
Python
# Folder containing the .safetensors files (This is where your Loras are)
input_folder = r"XXXXX" # ← Change this
# Folder for the cleaned files
output_folder = r"ZZZZZ" # ← Change thisExample (Windows):
Python
input_folder = r"C:\Users\YourName\Downloads\MyLoRAs"
output_folder = r"C:\Users\YourName\Downloads\Cleaned_LoRAs"Example (macOS / Linux):
Python
input_folder = r"/Users/YourName/Downloads/MyLoRAs"
output_folder = r"/Users/YourName/Downloads/Cleaned_LoRAs"Use r"..." (raw string) to avoid issues with backslashes on Windows.
The script will create the output folder automatically if it doesn't exist.
3. How to Run the Script
Option A: Run from Terminal / Command Prompt (Recommended)
Open a terminal / command prompt.
Navigate to the folder where the script is saved:
Bash
cd path/to/your/script/folderRun the script:
Bash
python metadata_remover_and_rename.pyor
Bash
python3 metadata_remover_and_rename.pyOption B: Run from an IDE (VS Code, PyCharm, etc.)
Open the file and click the "Run" button (or press F5 in many editors).
4. What to Expect
The script will process only .safetensors files in the input_folder.
For each file it will:
Load the model weights.
Save a new copy in the output_folder without any metadata.
You will see console output like:
text
Metadata removed: my_lora.safetensors
Metadata removed: another_model.safetensors
All files have been processed.Original files are not modified — they remain in the input folder.
5. Optional Improvements
Process subfolders recursively
This requires a small change (ask if you need help).
Add metadata (e.g., add your name or license)
Change the save line to:
Python
save_file(tensors, output_path, metadata={"author": "YourName", "license": "CC-BY-NC"})6. Troubleshooting
ModuleNotFoundError: No module named 'safetensors'
Run pip install safetensors
Permission errors
Run terminal as Administrator or use paths you have write access to
Script does nothing
Make sure input_folder contains .safetensors files and paths are correct
Large files take time
This is normal — big LoRAs can take several seconds each
7. Safety Notes
This script removes all metadata (author, trigger words, version info, etc.). Make sure you keep a backup of the original files if you need that information.
Always test a cleaned LoRA in your favorite UI (Forge,Automatic1111, ComfyUI, etc.) to ensure it still works.
Description
Looks like we don't have an active mirror for this file right now.
CivArchive is a community-maintained index — we catalog mirrors that volunteers upload to HuggingFace, torrents, and other public hosts. Looks like no one has uploaded a copy of this file yet.
Some files do get recovered over time through contributions. If you're looking for this one, feel free to ask in Discord, or help preserve it if you have a copy.
