{"id":19190847,"url":"https://github.com/flocked/fzmetadata","last_synced_at":"2025-05-08T04:50:47.061Z","repository":{"id":171467099,"uuid":"642901779","full_name":"flocked/FZMetadata","owner":"flocked","description":"File Metadata \u0026 File Query similar to Spotlight","archived":false,"fork":false,"pushed_at":"2025-04-29T15:23:43.000Z","size":2029,"stargazers_count":9,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-29T15:44:11.497Z","etag":null,"topics":["appkit","cocoa","macos","nsmetadata","nsmetadataitem","spotlight","uikit"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flocked.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-05-19T15:51:47.000Z","updated_at":"2025-04-29T15:23:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"a45c503d-6496-4ba6-bc29-9f7bd22fec27","html_url":"https://github.com/flocked/FZMetadata","commit_stats":null,"previous_names":["flocked/fzmetadata"],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flocked%2FFZMetadata","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flocked%2FFZMetadata/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flocked%2FFZMetadata/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flocked%2FFZMetadata/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flocked","download_url":"https://codeload.github.com/flocked/FZMetadata/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253002841,"owners_count":21838637,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["appkit","cocoa","macos","nsmetadata","nsmetadataitem","spotlight","uikit"],"created_at":"2024-11-09T11:36:00.049Z","updated_at":"2025-05-08T04:50:47.007Z","avatar_url":"https://github.com/flocked.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MetadataItem \u0026 MetadataQuery\n\nFile Metadata and File Query similar to Spotlight.\n\n**Take a look at the included sample app.**\n\n**For a full documentation take a look at the** [Online Documentation](https://swiftpackageindex.com/flocked/FZMetadata/documentation/).\n\n## MetadataItem\n\n`MetadataItem` lets you access the metadata of a file.\n\n```swift\nlet videoFile = URL(filePathWithString: pathToFile)\n\nif let metadata = videoFile.metadata {\n    metadata.duration // video duration\n    metadata.lastUsedDate // last usage date\n    metadata.pixelSize // video pixel size\n}\n```\n\n## MetadataQuery\n\nA file query that provides:\n- Blazing fast search of files simliar to Spotlight by predicate and attributes like file name, file size, last used date, video duration, etc.\n- Blazing fast query of attributes for large batches of files.\n- Monitoring of files and directories for updates to the search results.\n\n### Searching for files by location \u0026 predicate\n\nThe results handler gets called whenever new files meet the specified predicate at the search locations.\n\nThe predicate is constructed by comparing `MetadataItem` properties to values using operators and functions.\n\n```swift\nlet query = MetadataQuery()\n\n// Searches for files at the downloads and documents directory\nquery.searchLocations = [.downloadsDirectory, .documentsDirectory]\n\n// Image \u0026 videos files, added this week, large than 10mb\nquery.predicate = { \n    $0.fileTypes(.image, .video) \u0026\u0026 \n    $0.addedDate.isThisWeek \u0026\u0026 \n    $0.fileSize.megabytes \u003e= 10 \n}\n\nquery.resultsHandler = { files, _ in\n// found files\n}\nquery.start()\n```\n\n### Query of file attributes\n\nMetadataQuery provides blazing fast query of attributes for large batches of files. Fetching attributes for thousands of files often takes less than a second.\n\n```swift\n// URLs for querying of attributes\nquery.urls = videoFileURLs\n\n// Attributes to query\nquery.attributes = [.pixelSize, .duration, .fileSize, .creationDate]\n\nquery.resultsHandler = { files, _ in  \n    for file in files {\n    // file.pixelSize, file.duration, file.fileSize, file.creationDate\n    }\n}\nquery.start()\n```\n\n### Monitoring of files \u0026 directories\n\nMetadataQuery can monitor for changes to search results \u0026 queried attributes. It calls the completionHandler whenever changes happen.\n\nTo enable monitoring use `monitorResults()`.\n\n```swift\n// Files that are screenshots\nquery.predicate = { $0.isScreenCapture }\n\n// Searches everywhere on the local file system\nquery.searchScopes = [.local]\n\n// Enables monitoring. Whenever a new screenshot gets captures the results handler gets called\nquery.monitorResults = true\n\nquery.resultsHandler = { files, _ in\n    for file in files {\n    // screenshot files\n    }\n}\nquery.start()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflocked%2Ffzmetadata","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflocked%2Ffzmetadata","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflocked%2Ffzmetadata/lists"}