First, we store the path where we were before using pwd command. Then we go to the script directory and do work there assuming that we can do file operations in relation to the script folder. Then we return it back.

#!/usr/bin/env bash

cwd=$(pwd)
cd "$(dirname "$0")"

# now you are in your script dir
# do your staff here

cd $cwd

This allows run script that use related file path from any current path.