# List all maps in project or directory

**URL:** <https://forums.unrealengine.com/t/list-all-maps-in-project-or-directory/299256>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [November 18, 2014, 10:39am UTC](https://forums.unrealengine.com/t/list-all-maps-in-project-or-directory/299256 "2014-11-18T10:39:33Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nevermind\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Nevermind\_1](https://forums.unrealengine.com/u/Nevermind_1)\
**Post date:** [November 18, 2014, 10:39am UTC](https://forums.unrealengine.com/t/list-all-maps-in-project-or-directory/299256/1 "2014-11-18T10:39:33Z")

</div>

I want to create a simple level selector, that allows me to select a map to play. Right now I’ve hardcoded the list of maps, but it’s a clunky solution at best. Is there a way to list all maps included in project, or in specific directory? Preferably with blueprints, but C++ is OK too.

---

<div class="post-metadata">

**Author:** ![Nevermind\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Nevermind\_1](https://forums.unrealengine.com/u/Nevermind_1)\
**Post date:** [November 18, 2014, 2:07pm UTC](https://forums.unrealengine.com/t/list-all-maps-in-project-or-directory/299256/2 "2014-11-18T14:07:22Z")

</div>

So I’ve found a solution. The relevant classes are described here: [https://docs.unrealengine.com/latest/INT/Programming/Assets/AsyncLoading/index.html](https://docs.unrealengine.com/latest/INT/Programming/Assets/AsyncLoading/index.html)

Here’s my code

```
TArray<FString> UMyGameInstance::GetAllMapNames(){
	auto ObjectLibrary = UObjectLibrary::CreateLibrary(UWorld::StaticClass(), false, true);
	ObjectLibrary->LoadAssetDataFromPath(TEXT("/Game/Maps"));
	TArray<FAssetData> AssetDatas;
	ObjectLibrary->GetAssetDataList(AssetDatas);
	UE_LOG(LogTemp, Warning, TEXT("Found maps: %d"), AssetDatas.Num());

	TArray<FString> Names = TArray<FString>();

	for (int32 i = 0; i < AssetDatas.Num(); ++i)
	{
		FAssetData& AssetData = AssetDatas[i];

		auto name = AssetData.AssetName.ToString();
		Names.Add(name);
	}
	return Names;
}

```

This function is blueprint-accessible and used to populate map list in UI. I’m not completely sure it’s the correct way, but it does work.

---

<div class="post-metadata">

**Author:** ![eXi](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/exi/32/906583_2.png) [@eXi](https://forums.unrealengine.com/u/eXi)\
**Post date:** [November 18, 2014, 2:10pm UTC](https://forums.unrealengine.com/t/list-all-maps-in-project-or-directory/299256/3 "2014-11-18T14:10:59Z")

</div>

You can also have a look at the ShooterGame Project. I know that the 2 Maps are displayed in the UI to let the Player choose them, but they could be displayed by Slate (UMG Code).  
So maybe it’s not that easy to find, but this Project helps a lot 😃

---

<div class="post-metadata">

**Author:** ![Nevermind\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Nevermind\_1](https://forums.unrealengine.com/u/Nevermind_1)\
**Post date:** [November 18, 2014, 2:16pm UTC](https://forums.unrealengine.com/t/list-all-maps-in-project-or-directory/299256/4 "2014-11-18T14:16:45Z")

</div>

I’ve looked at ShooterGame first, and they just hardcode names:

```
static const FName PackageNames[] = { TEXT("test"), TEXT("Sanctuary.umap"), TEXT("Highrise.umap") };

```

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4b567b5a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4b567b5a](https://forums.unrealengine.com/u/anonymous_user_4b567b5a)\
**Post date:** [November 19, 2014, 7:41am UTC](https://forums.unrealengine.com/t/list-all-maps-in-project-or-directory/299256/5 "2014-11-19T07:41:36Z")

</div>

I did a search through the code, weird thing is that I didn’t find this ‘PackageNames’ is being referenced anywhere. Does anyone know how it affects things?

---

<div class="post-metadata">

**Author:** ![Patrik2991](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Patrik2991](https://forums.unrealengine.com/u/Patrik2991)\
**Post date:** [April 14, 2015, 8:48pm UTC](https://forums.unrealengine.com/t/list-all-maps-in-project-or-directory/299256/6 "2015-04-14T20:48:40Z")

</div>

Can you please make a blueprint function plugin from this, and publish it? Thank you!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_59bca5ba](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_59bca5ba](https://forums.unrealengine.com/u/anonymous_user_59bca5ba)\
**Post date:** [March 19, 2016, 1:26am UTC](https://forums.unrealengine.com/t/list-all-maps-in-project-or-directory/299256/7 "2016-03-19T01:26:49Z")

</div>

I used the answer above, but it wasn’t able to find maps in pak files from mods.

IFileManager::Get().FindFilesRecursive(MapFiles, _FPaths::GameContentDir(), TEXT("_.umap"), true, false);

Gets me a list of all umap files including ones in mods. You have to do a bit more string manipulation to get them in the format you want, but it’s working thus far for me.

---

<div class="post-metadata">

**Author:** ![Two-faced](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Two-faced](https://forums.unrealengine.com/u/Two-faced)\
**Post date:** [August 9, 2016, 8:39am UTC](https://forums.unrealengine.com/t/list-all-maps-in-project-or-directory/299256/8 "2016-08-09T08:39:47Z")

</div>

I’m sorry, what connection between your code and “answer above”??? i don’t even mention about how workable your code…

---

<div class="post-metadata">

**Author:** ![embiem](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@embiem](https://forums.unrealengine.com/u/embiem)\
**Post date:** [February 6, 2017, 1:11pm UTC](https://forums.unrealengine.com/t/list-all-maps-in-project-or-directory/299256/9 "2017-02-06T13:11:10Z")

</div>

this works great! I just had to make one change for it to work: the Filename string has to contain an asterisk “\*.umap”

My final utility function that I use to get all map file names in my project:

```
	UFUNCTION(BlueprintCallable, Category = "Utility")
	static FORCEINLINE TArray<FString> GetAllMapNames()
	{
		TArray<FString> MapFiles;

		IFileManager::Get().FindFilesRecursive(MapFiles, *FPaths::GameContentDir(), TEXT("*.umap"), true, false, false);

		for (int32 i = 0; i < MapFiles.Num(); i++)
		{
			// replace the whole directory string with only the name of the map

			int32 lastSlashIndex = -1;
			if (MapFiles[i].FindLastChar('/', lastSlashIndex))
			{
				FString pureMapName;

				// length - 5 because of the ".umap" suffix
				for (int32 j = lastSlashIndex + 1; j < MapFiles[i].Len() - 5; j++)
				{
					pureMapName.AppendChar(MapFiles[i][j]);
				}

				MapFiles[i] = pureMapName;
			}
		}

		return MapFiles;
	}
```

---

<div class="post-metadata">

**Author:** ![Luis\_Schmitz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Luis\_Schmitz](https://forums.unrealengine.com/u/Luis_Schmitz)\
**Post date:** [April 27, 2017, 5:05pm UTC](https://forums.unrealengine.com/t/list-all-maps-in-project-or-directory/299256/10 "2017-04-27T17:05:05Z")

</div>

[Get All Map Names Plugin - Content Creation - Unreal Engine Forums](https://forums.unrealengine.com/showthread.php?143407-Get-All-Map-Names-Plugin) I made a little plugin that gets all map names and gives back an array containing the names perfectly for level selection menus it contains the code mBeierling provided and some additional things.

---

<div class="post-metadata">

**Author:** ![gmachnik](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/gmachnik/32/1210677_2.png) [@gmachnik](https://forums.unrealengine.com/u/gmachnik)\
**Post date:** [February 7, 2019, 9:42am UTC](https://forums.unrealengine.com/t/list-all-maps-in-project-or-directory/299256/11 "2019-02-07T09:42:31Z")

</div>

Optimize Your code using ParseToArray:

```
	TArray<FString> temp, Lista;
	IFileManager::Get().FindFilesRecursive(Lista, *FPaths::GameContentDir(), TEXT("*.umap"), true, false, false);
	for (int i = 0; i < Lista.Num(); i++) {
		Lista[i].ParseIntoArray(temp, TEXT("Maps/"), true);
		Lista[i] = temp[1];
		Lista[i].ParseIntoArray(temp, TEXT("."), true);
		Lista[i] = temp[0];
	}
	return Lista;
}
```

---

<div class="post-metadata">

**Author:** ![hGosling](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@hGosling](https://forums.unrealengine.com/u/hGosling)\
**Post date:** [February 13, 2022, 1:55pm UTC](https://forums.unrealengine.com/t/list-all-maps-in-project-or-directory/299256/12 "2022-02-13T13:55:39Z")

</div>

For anyone finding this through Google search. This is how it’s done using Blueprint. You can also apply filters when working with the asset registry

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/6/1/c6157586cc8c65b833c1276e05b9a4317037967d.png)
