How do I copy a file with an absolute path outside of the gradle project

I am going crazy about this. I have been on this for hours trying to googling out a way to copy a file outside of the gradle project. How do I copy a file with an absolute path outside of the gradle project? I have a Sync task I would like to do it in

    into('/') {
        if (project.hasProperty("myfilepath")) {
            from(project.getProperty("myfilepath"), "$destinationDir/myNewFile")
        }
    }

My guess was to use from inside of into, but it seems I cannot get absolute path inside there.

You can use

from(new File('c:/absolute/path.txt'))

Thanks. And if I want it to be renamed in the process also?

You can use CopyTask.rename(…)

tasks.register('myCopy', Copy) {
   from(new File('c:/absolute/path'))
   into "$buildDir/somePath" 
   rename('(.*)\\.txt', 'foo$1.txt')
}