# (HTTP Request) Write each file with a different name upon downloading

**URL:** <https://forums.unrealengine.com/t/http-request-write-each-file-with-a-different-name-upon-downloading/449447>\
**Category:** Getting Started & Setup\
**Tags:** httprequest, unreal-engine, Installation, UE4, CPP, question\
**Created:** [May 23, 2019, 6:50am UTC](https://forums.unrealengine.com/t/http-request-write-each-file-with-a-different-name-upon-downloading/449447 "2019-05-23T06:50:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bazzy2000](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Bazzy2000](https://forums.unrealengine.com/u/Bazzy2000)\
**Post date:** [May 23, 2019, 6:50am UTC](https://forums.unrealengine.com/t/http-request-write-each-file-with-a-different-name-upon-downloading/449447/1 "2019-05-23T06:50:38Z")

</div>

I’ve created a downloader that downloads many files from a server at the same time. The problem that I’m having right now is my downloader overwrites a newer file with the old file that has been downloaded. Currently I have named every file “File” in my code after downloading, but I want my downloader to write/download the files in this pattern like “File0” “File1”, “File2” and so on. How can I get my downloader to write the files in this pattern “File0” “File1”, “File2”? More like increment the file “File” number.

---

<div class="post-metadata">

**Author:** ![Chkoupinator](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Chkoupinator](https://forums.unrealengine.com/u/Chkoupinator)\
**Post date:** [May 23, 2019, 10:44am UTC](https://forums.unrealengine.com/t/http-request-write-each-file-with-a-different-name-upon-downloading/449447/2 "2019-05-23T10:44:43Z")

</div>

I did a bit of research on it and it seems like listing files from a directory is possible, you could either copy paste the code found in [this answer](https://answers.unrealengine.com/questions/212791/how-to-get-file-list-in-a-directory.html) and get how many items are in the TArray (with .Num() ) or you could remove most of the unnecessary code for you and supply use the logic in there to increment a number.

Once you have your number you can simply use `FString::Printf(TEXT("File_%d.txt"), YourNumberOfFilesAsAnInt)` instead of `"File" + ".txt"` which btw is platform dependent and you should be using TEXT for

A second solution could be simply having a counter in the class of the downloader itself and using the same formatting method above, however if you use multi threading or if you think there could be multiple threads downloading at once this could potentially lead to issues (i.e. two threads reading it at once), you can use the same formatting option as above to get the counter into an FString

---

<div class="post-metadata">

**Author:** ![Chkoupinator](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Chkoupinator](https://forums.unrealengine.com/u/Chkoupinator)\
**Post date:** [May 23, 2019, 10:57am UTC](https://forums.unrealengine.com/t/http-request-write-each-file-with-a-different-name-upon-downloading/449447/3 "2019-05-23T10:57:37Z")

</div>

Edit: Forgot to add the link [https://answers.unrealengine.com/questions/212791/how-to-get-file-list-in-a-directory.html](https://answers.unrealengine.com/questions/212791/how-to-get-file-list-in-a-directory.html)
