# Flag to only copy files and not directory path

**URL:** <https://forum.rclone.org/t/flag-to-only-copy-files-and-not-directory-path/1636>\
**Category:** Help and Support\
**Created:** [April 5, 2017, 9:05pm UTC](https://forum.rclone.org/t/flag-to-only-copy-files-and-not-directory-path/1636 "2017-04-05T21:05:17Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Plex\_Test](https://forum.rclone.org/letter_avatar_proxy/v4/letter/p/eb9ed0/32.png) [@Plex\_Test](https://forum.rclone.org/u/Plex_Test)\
**Post date:** [April 5, 2017, 9:05pm UTC](https://forum.rclone.org/t/flag-to-only-copy-files-and-not-directory-path/1636/1 "2017-04-05T21:05:17Z")

</div>

Is there a flag so I can copy only files to the destination while traversing a directories on the source?

_Example:_

/mypath/  
/mypath/dir1/file1a  
/mypath/dir1/file2a  
/mypath/dir2/file1b  
/mypath/dir2/file2b

_desired output_  
/mydest/file1a  
/mydest/file2a  
/mydest/file1b  
/mydest/file2b

_Actual output_  
/mydest/dir1/file1a  
/mydest/dir1/file2a  
/mydest/dir2/file1b  
/mydest/dir2/file2b

---

<div class="post-metadata">

**Author:** ![chriscraig](https://forum.rclone.org/user_avatar/forum.rclone.org/chriscraig/32/419_2.png) [@chriscraig](https://forum.rclone.org/u/chriscraig)\
**Post date:** [April 6, 2017, 12:32am UTC](https://forum.rclone.org/t/flag-to-only-copy-files-and-not-directory-path/1636/2 "2017-04-06T00:32:01Z")

</div>

find /mypath -type f -exec rclone copy {} remote:/mydest ;

Will be slow, but it should work.

---

<div class="post-metadata">

**Author:** ![calisro](https://forum.rclone.org/user_avatar/forum.rclone.org/calisro/32/3130_2.png) [@calisro](https://forum.rclone.org/u/calisro)\
**Post date:** [April 6, 2017, 1:57am UTC](https://forum.rclone.org/t/flag-to-only-copy-files-and-not-directory-path/1636/3 "2017-04-06T01:57:45Z")

</div>

> [@chriscraig](#):
>
> find /mypath -type f -exec rclone copy {} remote:/mydest ;
> 
> Will be slow, but it should work.

Edit: I forgot my brain. Mine won't work. 🙂

If you produce an include list and put it in a file instead, then you can feed into rclone as a --files-from parameter. Would be much faster.

---

<div class="post-metadata">

**Author:** ![Plex\_Test](https://forum.rclone.org/letter_avatar_proxy/v4/letter/p/eb9ed0/32.png) [@Plex\_Test](https://forum.rclone.org/u/Plex_Test)\
**Post date:** [April 6, 2017, 3:32pm UTC](https://forum.rclone.org/t/flag-to-only-copy-files-and-not-directory-path/1636/6 "2017-04-06T15:32:27Z")

</div>

Thank you! I figured it out (with your help)!

`find "/mypath/" -mtime -1 -type l -exec rclone copy {} drive:tv -v -L \;`

---

<div class="post-metadata">

**Author:** ![scsuperlight](https://forum.rclone.org/letter_avatar_proxy/v4/letter/s/e9a140/32.png) [@scsuperlight](https://forum.rclone.org/u/scsuperlight)\
**Post date:** [December 12, 2019, 6:06pm UTC](https://forum.rclone.org/t/flag-to-only-copy-files-and-not-directory-path/1636/7 "2019-12-12T18:06:56Z")

</div>

> [@calisro](#):
>
> --files-from

Hello, I know i'm late to the party here, but has anyone figured out a better/easier way to do this? I have 58 million files and can't execute rclone each time, and an include file would be crazy big. Is it possible to just set the object key = to the filename?

---

<div class="post-metadata">

**Author:** ![scsuperlight](https://forum.rclone.org/letter_avatar_proxy/v4/letter/s/e9a140/32.png) [@scsuperlight](https://forum.rclone.org/u/scsuperlight)\
**Post date:** [December 13, 2019, 3:08pm UTC](https://forum.rclone.org/t/flag-to-only-copy-files-and-not-directory-path/1636/8 "2019-12-13T15:08:17Z")

</div>

Thanks, when I try files-from I still get the object showing up with the full path:

Key: /layer\_test/layer2/21294\_1000-1-1-1-8-1-1\_1575900260.613.ts

my filter1.txt has:

# a sample filter rule file

/layer\_test/layer2/21294\_1000-1-1-1-8-1-1\_1575900260.613.ts

and I call it with:  
rclone copy --files-from C:\R\_Clone2\filter1.txt C:\R\_Clone2 leyb\_large:inear-root/ --no-check-certificate

it copies the 1 file ok, but It still shows up with the object key having the directories there, I need it to not have the /layer\_test/layer2/ dragged along with it as the object key.

what am I doing wrong here? Thanks for the help.

---

<div class="post-metadata">

**Author:** ![scsuperlight](https://forum.rclone.org/letter_avatar_proxy/v4/letter/s/e9a140/32.png) [@scsuperlight](https://forum.rclone.org/u/scsuperlight)\
**Post date:** [December 13, 2019, 3:47pm UTC](https://forum.rclone.org/t/flag-to-only-copy-files-and-not-directory-path/1636/9 "2019-12-13T15:47:18Z")

</div>

forgot to add a log, here is what it looks like with lsl -vv: just trying to get rid of the layer\_test/layer2/ part, The file lives here on local, filter finds it ok, just can't have all this showing up in S3.  
C:\R\_Clone2\layer\_test\layer2\21294\_1000-1-1-1-8-1-1\_1575900260.613.ts

C:\R\_Clone\>rclone --no-check-certificate lsl leyb\_large:inear-root/ -vv  
2019/12/13 10:38:20 DEBUG : rclone: Version "v1.50.1-047-gec09127b-fix-netapp-creation-time-beta" starting with parameters ["rclone" "--no-check-certificate" "lsl" "leyb\_large:inear-root/" "-vv"]  
2019/12/13 10:38:20 DEBUG : Using config file from "C:\Users\pema9013\.config\rclone\rclone.conf"  
19135956 2019-12-09 09:09:21.000000000 \*\*layer\_test/layer2/\*\*21294\_1000-1-1-1-8-1-1\_1575900260.613.ts  
2019/12/13 10:38:21 DEBUG : 5 go routines active  
2019/12/13 10:38:21 DEBUG : rclone: Version "v1.50.1-047-gec09127b-fix-netapp-creation-time-beta" finishing with parameters ["rclone" "--no-check-certificate" "lsl" "leyb\_large:inear-root/" "-vv"]

Thanks, Nick got me over a few hurdles so far, almost at the finish line here, much appreciated.

---

<div class="post-metadata">

**Author:** ![ncw](https://forum.rclone.org/user_avatar/forum.rclone.org/ncw/32/18_2.png) [@ncw](https://forum.rclone.org/u/ncw)\
**Post date:** [December 14, 2019, 12:01pm UTC](https://forum.rclone.org/t/flag-to-only-copy-files-and-not-directory-path/1636/10 "2019-12-14T12:01:50Z")

</div>

> [@scsuperlight](#):
>
> here is what it looks like with lsl -vv: just trying to get rid of the layer\_test/layer2/ part,

If you don't want the `layer_test/layer2` part then you need to change your `--files-from` so it isn't present in there. This might mean you need a different files from for each directory in the source.

Rclone doesn't currently have a flatten operation which would copy all the files in the source into the same directory in the destination which is what I think you are asking for.

---

<div class="post-metadata">

**Author:** ![scsuperlight](https://forum.rclone.org/letter_avatar_proxy/v4/letter/s/e9a140/32.png) [@scsuperlight](https://forum.rclone.org/u/scsuperlight)\
**Post date:** [December 14, 2019, 4:33pm UTC](https://forum.rclone.org/t/flag-to-only-copy-files-and-not-directory-path/1636/11 "2019-12-14T16:33:24Z")

</div>

thank you Sir, you have been a great help. We figured out a way to loop through the folders and issue an rclone copy for each, we don't have to cd into every directory to do this which is great. I still owe you a pizza! Happy holidays :o)

---

<div class="post-metadata">

**Author:** ![scsuperlight](https://forum.rclone.org/letter_avatar_proxy/v4/letter/s/e9a140/32.png) [@scsuperlight](https://forum.rclone.org/u/scsuperlight)\
**Post date:** [December 14, 2019, 4:40pm UTC](https://forum.rclone.org/t/flag-to-only-copy-files-and-not-directory-path/1636/12 "2019-12-14T16:40:51Z")

</div>

I'll share our solution when it works!

---

<div class="post-metadata">

**Author:** ![system](https://forum.rclone.org/uploads/default/original/2X/3/39ad3235f6ffec76ccd0c81616bd55697b4c300d.png) [@system](https://forum.rclone.org/u/system)\
**Post date:** [March 4, 2020, 12:37am UTC](https://forum.rclone.org/t/flag-to-only-copy-files-and-not-directory-path/1636/13 "2020-03-04T00:37:21Z")

</div>

Closed on March 4, 2020, 12:37am UTC


