Loop through files in directory and zip
<p>I am trying to make a bash script to loop through all files in a directory, and individually zip them to another directory.</p>

<p>Currently I have this:</p>

<pre class="lang-sh prettyprint-override"><code>FILES=/media/user/storage/unzipped/*
for f in $FILES
do
  7za a -t7z /media/user/storage/zipped/$f.7z $f -mx9 -r -ppassword -mhe
done
</code></pre>

<p>The problem is that the variable $f includes the absolute path to the source file, so my output file ends up in /media/user/storage/zipped/media/user/storage/unzipped/</p>

<p>How can I extract only the name from the $f variable?</p>