If manually editing the patch file is out of the question or infeasible, this can be done with standard options (available in git apply, git format-patch and GNU patch).
-
-p<n>removesnleading directories from the paths in the patch. -
After processing
-p,--directory=<root>prependsrootto each of the paths in the patch before applying.
Example
So, for your example, to take a patch that was originally on static/playdar.js and apply it to lib/playdar.js, you would run:
$ cat patch_file | git am \
-p1 \ # remove 1 leading directory ('static/')
--directory='lib/' # prepend 'lib/'