Groovy - Replacing all folders in a directory

I have a folder located C:\Program Files\VideoEditing, and inside there I have about 30 folders that I would like to make a zip. In doing so, I would like to add an image to each new folder. (image location C:\Program Files\VideoEditing\art.png).

I was wondering, is it possible, how is it possible in groovy?

My goal is to have 60 directories / folders in my VideoEditing directory. (30 - originals and 30 zipped versions with an image inside it)

I am going to continue to search for additional information on this topic, but thought that I could also publish it if someone already knows how to do it.

.

EDIT

Based on the andrei1089 suggestion of using AntBuilder, I assume that the code will look something like this:

File file = new File('C:\\Program Files\\VideoEditing')

fileDir = []
def ant = new AntBuilder()
int i = 0

file.eachDir {
    fileDir << it
}

fileDir.each { 
    ant.zip(//new file name = VidFolder_$i,
        //include folder,
        //include art.png,)    
}

, , , , .

+3
2

new AntBuilder().with {
  new File('src').eachDir {dir->
    zip destfile: "${dir.name}.zip", {
      fileset dir: dir
      fileset file: 'src/file.txt'
    }
  }
}

, ,

+4

AntBuilder.

+1

Source: https://habr.com/ru/post/1790232/


All Articles