Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-2026

How can i iterate recursively through OS Directories and check for files & directories ?

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Won't Fix
    • None
    • 1.1-rc-3
    • None
    • None

    Description

      Hi Groovy Geeks

      Please help me to get rectify the following code..

      String srcDir = "C:/MyTest"
      String destDir = "C:/MyTestDest"

      File rootDir = new File("$srcDir")
      rootDir.each {
      println it
      File musicDir = new File(it)
      if(musicDir.exists() && musicDir.isDirectory()) {
      println "1:" + it
      musicDir.eachFile { artistDir ->
      if (artistDir.isDirectory()) {
      println "2:" + artistDir
      artistDir.eachFileMatch('.')

      { file -> println "3:" + file }

      }
      }
      }
      }

      I'm getting the following error..

      Caught: java.io.FileNotFoundException: C:\MyTest (Access is denied)
      at FileTest.run(FileTest.groovy:33)
      at FileTest.main(FileTest.groovy)

      --I want to iterate through the os directories and want to move the directories and files to other destination folder.

      Attachments

        Activity

          People

            Unassigned Unassigned
            geek_jay geek_jay
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: