Install and ack all files in a directory

I downloaded multiple snaps before reinstalling my os. So now I have a directory with multiple snap and assert files.
Is there any way to install and assert all of them without doing it one by one manually.
(if not, if you have a shell script to achieve this, can you please share it)

here is a simple (untested) script:

#! /bin/sh

[ -n "$downloadpath" ] || exit 1

for file in $downloadpath/*.snap; do
  assert=$(echo $file|sed 's/.snap$//')

  sudo snap ack $assert.assert
  sudo snap install $file

just call it with the dir that has the snap and assert file as the first option …


thanks man, works perfectly.