How can I copy content of all subfolders of given folder using Ant?
i.e. I have such folder structure
folder/
folder/sub1/1.txt
folder/sub1/f1/1.txt
folder/sub2/2.txt
...
I don't know exact names of subfolders. And I need to copy content from all of them into one folder (keeping the structure of content, i.e. copying all files into one dir using flatten isn't a solution). I need to get
newfolder/1.txt
newfolder/1/1.txt
newfolder/2.txt
...
Does fileset allows to group subfolders in such a way?
**
stands for zero or more directories, and usage of *
as directory name is disallowed, i.e. <fileset dir="${dir}/*/" />
isn't acceptable.
Thanks in advance, Yury
To copy multiple files with the “cp” command, navigate the terminal to the directory where files are saved and then run the “cp” command with the file names you want to copy and the destination path. Above mentioned scenarios are how to copy a single or selected file in a directory.
<copy toDir="newfolder">
<fileset dir="folder">
<include name="*/**"/>
<exclude name="*"/>
</fileset>
<regexpmapper from="^[^/]*/(.*)$$" to="\1" handledirsep="true"/>
</copy>
You only need to specify handledirsep
if you ever intend to run this script in Windows.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With