# Move certain files while retaining folder structure

**URL:** https://resource.dopus.com/t/move-certain-files-while-retaining-folder-structure/27843
**Category:** Help & Support
**Created:** [January 23, 2018, 9:25pm UTC](https://resource.dopus.com/t/move-certain-files-while-retaining-folder-structure/27843 "2018-01-23T21:25:35Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![mojo-chan](https://resource.dopus.com/letter_avatar_proxy/v4/letter/m/b77776/32.png) [@mojo-chan](https://resource.dopus.com/u/mojo-chan)
#### Post date: [January 23, 2018, 9:25pm UTC](https://resource.dopus.com/t/move-certain-files-while-retaining-folder-structure/27843/1 "2018-01-23T21:25:36Z")

</div>

I have a load of deep directories containing a mixture of file types. I want to separate out the files by type, but retaining the directory structure.

So for example I have:

web/site1/index.html  
web/site1/image.jpg  
web/site2/index.html  
web/site2/image.jpg

And I want:

html/site1/index.html  
html/site2/index.html  
images/site1/image.jpg  
images/site2/image.jpg

I found this ancient thread: [Copy/Move specific files to an identical folder structure](https://resource.dopus.com/t/copy-move-specific-files-to-an-identical-folder-structure/413)

Is there a better way to do this 13 years later? I've got about 2.7TB of files so I'd prefer to rename (move) them rather than copy and delete them.

It's a 10 minute job in C# but I thought Opus might be able to do it.

---

<div class="post-metadata">

### Author: ![Leo](https://resource.dopus.com/user_avatar/resource.dopus.com/leo/32/69732_2.png) [@Leo](https://resource.dopus.com/u/Leo)
#### Post date: [January 23, 2018, 10:09pm UTC](https://resource.dopus.com/t/move-certain-files-while-retaining-folder-structure/27843/2 "2018-01-23T22:09:27Z")

</div>

That should be fairly easy with a rename script. Just have the script code look at the extension and choose a folder to move (rename) the files into.

If you want help writing the script, please give a full specification of what you want it to do, including all the different extensions and directories they should go in, and an example before & after list of paths.

---

<div class="post-metadata">

### Author: ![Jon](https://resource.dopus.com/user_avatar/resource.dopus.com/jon/32/12713_2.png) [@Jon](https://resource.dopus.com/u/Jon)
#### Post date: [January 23, 2018, 10:17pm UTC](https://resource.dopus.com/t/move-certain-files-while-retaining-folder-structure/27843/3 "2018-01-23T22:17:10Z")

</div>

Possibly this script might already do what you want (or not need much modification):

> [@Rename a folder based on the file type extension](https://resource.dopus.com/t/rename-a-folder-based-on-the-file-type-extension/6267/9):
>
> This requires Opus 12.0.8 or above as it uses the new $.\ feature which makes it easier to move things into sub-folders of the starting point. Before: After: [image] What the rename dialog looks like: The script code: fun…

---

<div class="post-metadata">

### Author: ![mojo-chan](https://resource.dopus.com/letter_avatar_proxy/v4/letter/m/b77776/32.png) [@mojo-chan](https://resource.dopus.com/u/mojo-chan)
#### Post date: [January 24, 2018, 6:31pm UTC](https://resource.dopus.com/t/move-certain-files-while-retaining-folder-structure/27843/4 "2018-01-24T18:31:03Z")

</div>

Thanks. I thought about adapting that script, but in the end just wrote this: [https://github.com/kuro68k/FileSieve](https://github.com/kuro68k/FileSieve)
