Get Folder Names of a Collection

Hi @hbertsch!

Outside of creating a Collection object, there isn’t a Sandbox method for getting folder name right now (but we do have an open feature request for it)

How many folders are you dealing with? What about this:

In each folder, add a pre-request script that sets a local variable with the name of the folder. You’d have to hard-code the folder name value, but if you don’t have a ton of folders this could work:

Folder A —> Pre-request script —> pm.variables.set('folder_name','Folder A');

Then, any script in your Collection can access the current folder name by using:
pm.variables.get('folder_name');

When the Collection run moves to the next folder, that folder would (ideally) contain the same script, but with it’s own value.

2 Likes