Macros

I am new to macros. I am looking for a couple of things, any help is appreciated:

1) In a macro, how to get the repository folder name for a given diagram

2) a sample macros that goes against a repository diagram, but contains the necessary setup to be run from the command line. Setup like calls to login to the repository ..etc

Thanks