Find Directory from array of file names with paths

I have a script that generates a variable with the location of a file and its complete path. What i want to do is to "cd" to the directory where that file is located using the path name of the file. GIS has absolutely failed me.

For example when i run my script it generates a variable called $f. When i cat it i get.

/Users/myuser/Documents/MemSVC_5493/MemSVC.html

No i want to cd to the directory:

/Users/myuser/Documents/MemSVC_5493/

How can i do this?

What i really want to do is grep stuff in that file and then create a file with the name of the current directory.

At first: Use CODE-tags when posting code, data or logs for better readability, ty.

No idea what GIS is.

Anyway as a start:

$> VAR=/Users/myuser/Documents/MemSVC_5493/MemSVC.html
$> cd ${VAR%/*}

If you want to write the new file with the same name as the current directory you can use something like

$> VAR2=/Users/myuser/Documents/MemSVC_5493
$> echo ${VAR2##*/}
MemSVC_5493

If you want to use the current path as filename, I would change the slashes vs. underscores maybe.