# How to get folders inside of a folder?

**URL:** <https://forums.unrealengine.com/t/how-to-get-folders-inside-of-a-folder/390497>\
**Category:** Modding\
**Tags:** folder, unreal-engine, Modding, CPP, question\
**Created:** [April 10, 2017, 9:54pm UTC](https://forums.unrealengine.com/t/how-to-get-folders-inside-of-a-folder/390497 "2017-04-10T21:54:30Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Motanum](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Motanum](https://forums.unrealengine.com/u/Motanum)\
**Post date:** [April 10, 2017, 9:54pm UTC](https://forums.unrealengine.com/t/how-to-get-folders-inside-of-a-folder/390497/1 "2017-04-10T21:54:30Z")

</div>

Hello,

Just as I can use the next function to find all available files inside of a folder.

```
bool UMusicalRangeBPFunctionLibrary::LoadFromFileGetAvailableFiles(TArray<FString>& Files, FString FullFilePath) {
	FPaths::NormalizeDirectoryName(FullFilePath);
	IFileManager& FileManager = IFileManager::Get();

	FString FinalPath = FullFilePath + "/";
	FileManager.FindFiles(Files, *FinalPath, NULL);

	for (int i = 0; i < Files.Num(); i++)
	{
		UE_LOG(LogMusicalRange, Log, TEXT("File Found: %s"), *Files[i]);
	}
	return true;
}

```

How can I do something similar to find the folders inside of a folder? So, for example, I have a folder named “CustomSongs”, and I want to be able to get the name of all the folders inside of the folder CustomSongs.

Cheers!

---

<div class="post-metadata">

**Author:** ![staticvoidlol](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@staticvoidlol](https://forums.unrealengine.com/u/staticvoidlol)\
**Post date:** [April 11, 2017, 11:59am UTC](https://forums.unrealengine.com/t/how-to-get-folders-inside-of-a-folder/390497/2 "2017-04-11T11:59:16Z")

</div>

It seems that the function you’re already using ([IFileManager::FindFiles](https://docs.unrealengine.com/latest/INT/API/Runtime/Core/HAL/IFileManager/index.html)) has overloads that cater for directories.

I suppose the following should work, but can’t test right now:

```
FileManager.FindFiles(Files, *FinalPath, false, true);

```

---

<div class="post-metadata">

**Author:** ![Motanum](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Motanum](https://forums.unrealengine.com/u/Motanum)\
**Post date:** [April 11, 2017, 3:47pm UTC](https://forums.unrealengine.com/t/how-to-get-folders-inside-of-a-folder/390497/3 "2017-04-11T15:47:50Z")

</div>

I just tried this out like this.

```
bool UMusicalRangeBPFunctionLibrary::LoadFromFileGetAvailableFolders(TArray<FString>& Folders, FString FullFilePath, bool printFolders) {
	FPaths::NormalizeDirectoryName(FullFilePath);
	IFileManager& FileManager = IFileManager::Get();

	FString FinalPath = FullFilePath + "/";
	FileManager.FindFiles(Folders, *FinalPath, false, true);

	if (printFolders)
	{
		for (int i = 0; i < Folders.Num(); i++)
		{
			UE_LOG(LogMusicalRange, Log, TEXT("File Found: %s"), *Folders[i]);
		}
	}
	return true;
}

```

Blueprint returned an empty array.

[http://puu.sh/vgQlP/6213cb2767.jpg](http://puu.sh/vgQlP/6213cb2767.jpg)

And the folder in question I am searching.

[http://puu.sh/vgQoH/e8d3756789.png](http://puu.sh/vgQoH/e8d3756789.png)

---

<div class="post-metadata">

**Author:** ![staticvoidlol](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@staticvoidlol](https://forums.unrealengine.com/u/staticvoidlol)\
**Post date:** [April 13, 2017, 8:14am UTC](https://forums.unrealengine.com/t/how-to-get-folders-inside-of-a-folder/390497/4 "2017-04-13T08:14:58Z")

</div>

Not sure why it won’t work. Have you tried [IterateDirectory](https://docs.unrealengine.com/latest/INT/API/Runtime/Core/HAL/IFileManager/IterateDirectory/index.html)?

---

<div class="post-metadata">

**Author:** ![Motanum](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Motanum](https://forums.unrealengine.com/u/Motanum)\
**Post date:** [April 13, 2017, 9:40pm UTC](https://forums.unrealengine.com/t/how-to-get-folders-inside-of-a-folder/390497/5 "2017-04-13T21:40:19Z")

</div>

So I just tried the following code.

```
bool UMusicalRangeBPFunctionLibrary::LoadFromFileGetAvailableFolders(TArray<FString>& Folders, FString FullFilePath, bool printFolders) {
	FPaths::NormalizeDirectoryName(FullFilePath);
	IFileManager& FileManager = IFileManager::Get();

	FileManager.FindFiles(Folders, *FullFilePath, true, true);

	if (printFolders)
	{
		for (int i = 0; i < Folders.Num(); i++)
		{
			UE_LOG(LogMusicalRange, Log, TEXT("File Found: %s"), *Folders[i]);
		}
	}
	return true;
}

```

And it fails to load anything. No extensions, no files within, it seems to return the last folder in /foldername/.

[http://puu.sh/vjmCe/9da494a386.png](http://puu.sh/vjmCe/9da494a386.png)

And the actual folder in Windows Explorer

[http://puu.sh/vjmEt/81257341a2.png](http://puu.sh/vjmEt/81257341a2.png)

---

<div class="post-metadata">

**Author:** ![GigasightMedia](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GigasightMedia](https://forums.unrealengine.com/u/GigasightMedia)\
**Post date:** [April 15, 2017, 3:25am UTC](https://forums.unrealengine.com/t/how-to-get-folders-inside-of-a-folder/390497/6 "2017-04-15T03:25:40Z")

</div>

The path you send is treated as a specific filename unless you include a wildcard character.

Try:

```
FString FinalPath = FullFilePath / TEXT("*");
FileManager.FindFiles(Folders, *FinalPath, false, true);

```

Also, I haven’t tested this, but the documentation for FindFiles says “files or directories” rather than “files and/or directories” so you may not be able to pass “true” to both. I’d be a bit surprised by that, but if you still have trouble it’s worth a shot just doing one or the other.

---

<div class="post-metadata">

**Author:** ![Motanum](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Motanum](https://forums.unrealengine.com/u/Motanum)\
**Post date:** [April 17, 2017, 2:47pm UTC](https://forums.unrealengine.com/t/how-to-get-folders-inside-of-a-folder/390497/7 "2017-04-17T14:47:59Z")

</div>

This did it!

---

<div class="post-metadata">

**Author:** ![Ertie](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ertie/32/467698_2.png) [@Ertie](https://forums.unrealengine.com/u/Ertie)\
**Post date:** [February 5, 2021, 9:54pm UTC](https://forums.unrealengine.com/t/how-to-get-folders-inside-of-a-folder/390497/8 "2021-02-05T21:54:36Z")

</div>

Thanks! Didn’t know I had to include a " \* " and was having trouble.
