Skip to content

Bash version #4

Description

@Fmstrat

In case you want a super-short bash script that does the same thing:

#!/bin/bash

USED_MODELS=$(perl -nle 'while (/\[([^ \]]*\.[^ \]]*)\]/g) { print $1 }' ~/Documents/ComfyUI/user/default/workflows/*.json |grep -v '{' |sed 's/"//g;s/,/ /g')
MODELS=$(find /Users/user/Documents/ComfyUI/models -type f |grep -v "\.cache")

for MODEL in ${MODELS}; do
	BASE_NAME=$(basename "${MODEL}")
	FOUND=false
	for USED_MODEL in ${USED_MODELS}; do
		if [ "${BASE_NAME}" = "${USED_MODEL}" ]; then
			FOUND=true
			break
		fi
	done
	if [ "${FOUND}" = "false" ]; then
		echo "rm '${MODEL}'"
	fi
done

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions