<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CreateMLComponents",
  "identifier" : "/documentation/CreateMLComponents/AnnotatedFiles/init(labeledBySubdirectoryNamesAt:type:continueOnFailure:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Create ML Components",
      "CreateMLComponents"
    ],
    "preciseIdentifier" : "s:18CreateMLComponents14AnnotatedFilesV28labeledBySubdirectoryNamesAt4type17continueOnFailureAC10Foundation3URLV_22UniformTypeIdentifiers6UTTypeVSbtKcfc"
  },
  "title" : "init(labeledBySubdirectoryNamesAt:type:continueOnFailure:)"
}
-->

# init(labeledBySubdirectoryNamesAt:type:continueOnFailure:)

Reads training examples from a directory containing files in labeled sub-directories.

```
init(labeledBySubdirectoryNamesAt url: URL, type: UTType, continueOnFailure: Bool = false) throws
```

## Parameters

`url`

URL of directory containing the files.

`type`

Type of files.

`continueOnFailure`

A Boolean value indicating whether to continue reading files after
encountering a file that is not readable. The default value is `false`.

## Discussion

Take for example this directory structure:

```
/
    foo/
        file1.png
        file2.png
    bar/
        file3.png
        file4.png
```

It would produce two labels (foo and bar) with two URLs each.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)