# Get folder name in pre-request script section

**URL:** <https://community.postman.com/t/get-folder-name-in-pre-request-script-section/21597>\
**Category:** Help Hub\
**Tags:** collections\
**Created:** [March 19, 2021, 3:23pm UTC](https://community.postman.com/t/get-folder-name-in-pre-request-script-section/21597 "2021-03-19T15:23:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![postmanlen](https://avatars.discourse-cdn.com/v4/letter/p/e79b87/32.png) [@postmanlen](https://community.postman.com/u/postmanlen)\
**Post date:** [March 19, 2021, 3:23pm UTC](https://community.postman.com/t/get-folder-name-in-pre-request-script-section/21597/1 "2021-03-19T15:23:40Z")

</div>

We have a large number of requests in a collection manage in separate folders. I am trying to retrieve the name of the folder for the request in the pre-request script section. Is there any property available in pm object for the same?

---

<div class="post-metadata">

**Author:** ![Kurmavatar](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/kurmavatar/32/3026_2.png) [@Kurmavatar](https://community.postman.com/u/Kurmavatar)\
**Post date:** [March 23, 2021, 9:01am UTC](https://community.postman.com/t/get-folder-name-in-pre-request-script-section/21597/2 "2021-03-23T09:01:02Z")

</div>

Hi @postmanlen

This thread below should help you with this:

> [@Get Folder Names of a Collection](https://community.postman.com/t/get-folder-names-of-a-collection/9516/2):
>
> 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](https://github.com/postmanlabs/postman-app-support/issues/6926)) 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…

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [December 12, 2024, 12:57pm UTC](https://community.postman.com/t/get-folder-name-in-pre-request-script-section/21597/3 "2024-12-12T12:57:17Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
