I don't have any applicable test data but this should work (in theory) while illuminating a couple defensive strategies:
(defun foo ( old_style new_style / ss i c pair ename data )
(cond
( (null (tblsearch "dimstyle" (setq new_style (strcase new_style))))
(princ (strcat "\nError: New dimstyle <" new_style "> does not exist."))
)
( (null (setq ss (ssget "_x" (list '(0 . "dimension") (cons 3 (setq old_style (strcase old_style)))))))
(princ (strcat "\nNo dimensions sporting dimstyle <" old_style ">."))
)
( (setq c 0 pair (cons 3 new_style))
(repeat (setq i (sslength ss))
(vl-catch-all-apply 'entmod
(list
(subst
pair
(assoc 3 (setq data (entget (setq ename (ssname ss (setq i (1- i)))))))
data
)
)
)
(if (eq new_style (strcase (cdr (assoc 3 (entget ename)))))
(setq c (1+ c))
)
)
(princ (strcat "\nSuccessfully changed <" (itoa c) "> dim entities to dimstyle <" new_style ">."))
)
)
(princ)
)
(defun c:foo ( )
(foo "dimen_new" "dimen")
)