Using below bash script we can register all the vms in datastores with ESXi host.This has tested in vSphere 6.5 & 6.7 Hol
for myvm in $(find / -name *.vmx);
do
vim-cmd solo/registervm $myvm
done
if we want we can find on specific datastore. please refer the below example
find /vmfs/voluems/datastore10R10/ -name *.vmx
(datastore10R10 is my datatore name)