All Projects → JohnSundell → Files

JohnSundell / Files

Licence: mit
A nicer way to handle files & folders in Swift

Programming Languages

swift
15916 projects
ruby
36898 projects - #4 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to Files

Voila
Voila is a domain-specific language launched through CLI tool for operating with files and directories in massive amounts in a fast & reliable way.
Stars: ✭ 78 (-96.44%)
Mutual labels:  files, folders
dirgen
Generate files and folders from a template file
Stars: ✭ 21 (-99.04%)
Mutual labels:  files, folders
Marathon
[DEPRECATED] Marathon makes it easy to write, run and manage your Swift scripts 🏃
Stars: ✭ 1,889 (-13.7%)
Mutual labels:  xcode, swift-script
diskusage
FANTASTIC SPEED utility to find out top largest folders/files on the disk.
Stars: ✭ 64 (-97.08%)
Mutual labels:  files, folders
Licenseplist
A license list generator of all your dependencies for iOS applications
Stars: ✭ 1,996 (-8.82%)
Mutual labels:  xcode
React Native Unified Contacts
Your best friend when working with the latest and greatest Contacts Framework in iOS 9+ in React Native.
Stars: ✭ 156 (-92.87%)
Mutual labels:  xcode
Alerttoast
Create Apple-like alerts & toasts using SwiftUI
Stars: ✭ 151 (-93.1%)
Mutual labels:  xcode
Zewo
Lightweight library for web server applications in Swift on macOS and Linux powered by coroutines.
Stars: ✭ 1,856 (-15.21%)
Mutual labels:  xcode
Exa
A modern replacement for ‘ls’.
Stars: ✭ 15,471 (+606.76%)
Mutual labels:  files
Zip
Swift framework for zipping and unzipping files.
Stars: ✭ 2,120 (-3.15%)
Mutual labels:  files
Learning React Native
React Native Learning Notebook
Stars: ✭ 158 (-92.78%)
Mutual labels:  xcode
Accordionswift
The best way of implement an accordion menu using an UITableView in Swift
Stars: ✭ 156 (-92.87%)
Mutual labels:  xcode
Zkcarousel
A simple carousel implementation written in Swift
Stars: ✭ 163 (-92.55%)
Mutual labels:  xcode
Assetchecker
👮Sanitize your Assets.xcassets files
Stars: ✭ 167 (-92.37%)
Mutual labels:  xcode
Cdmarkdownkit
An extensive Swift framework providing simple and customizable markdown parsing.
Stars: ✭ 158 (-92.78%)
Mutual labels:  xcode
Comment Spell Checker
Xcode extension for spell checking and auto-correcting code comments.
Stars: ✭ 155 (-92.92%)
Mutual labels:  xcode
Xcode Clean.sh
Bash script freeing up disk space by removing Xcode generated data
Stars: ✭ 164 (-92.51%)
Mutual labels:  xcode
Whats New In Swift 4
An Xcode playground showcasing the new features in Swift 4.0.
Stars: ✭ 1,860 (-15.03%)
Mutual labels:  xcode
Pulley
A library to imitate the iOS 10 Maps UI.
Stars: ✭ 1,928 (-11.92%)
Mutual labels:  xcode
Fselect
Find files with SQL-like queries
Stars: ✭ 3,103 (+41.75%)
Mutual labels:  files

“Files”

BuddyBuild CocoaPods Carthage Swift Package Manager Twitter: @johnsundell

Welcome to Files, a compact library that provides a nicer way to handle files and folders in Swift. It’s primarily aimed at Swift scripting and tooling, but can also be embedded in applications that need to access the file system. It's essentially a thin wrapper around the FileManager APIs that Foundation provides.

Features

  • Modern, object-oriented API for accessing, reading and writing files & folders.
  • Unified, simple do, try, catch error handling.
  • Easily construct recursive and flat sequences of files and folders.

Examples

Iterate over the files contained in a folder:

for file in try Folder(path: "MyFolder").files {
    print(file.name)
}

Rename all files contained in a folder:

try Folder(path: "MyFolder").files.enumerated().forEach { (index, file) in
    try file.rename(to: file.nameWithoutExtension + "\(index)")
}

Recursively iterate over all folders in a tree:

Folder.home.subfolders.recursive.forEach { folder in
    print("Name : \(folder.name), parent: \(folder.parent)")
}

Create, write and delete files and folders:

let folder = try Folder(path: "/users/john/folder")
let file = try folder.createFile(named: "file.json")
try file.write("{\"hello\": \"world\"}")
try file.delete()
try folder.delete()

Move all files in a folder to another:

let originFolder = try Folder(path: "/users/john/folderA")
let targetFolder = try Folder(path: "/users/john/folderB")
try originFolder.files.move(to: targetFolder)

Easy access to system folders:

Folder.current
Folder.root
Folder.library
Folder.temporary
Folder.home
Folder.documents

Installation

Files can be easily used in either a Swift script, a command line tool, or in an app for iOS, macOS, tvOS or Linux.

Using the Swift Package Manager (preferred)

To install Files for use in a Swift Package Manager-powered tool, script or server-side application, add Files as a dependency to your Package.swift file. For more information, please see the Swift Package Manager documentation.

.package(url: "https://github.com/JohnSundell/Files", from: "4.0.0")

Using CocoaPods or Carthage

Please refer to CocoaPods’ or Carthage’s own documentation for instructions on how to add dependencies using those tools.

As a file

Since all of Files is implemented within a single file, you can easily use it in any project by simply dragging the file Files.swift into your Xcode project.

Backstory

So, why was this made? As I've migrated most of my build tools and other scripts from languages like Bash, Ruby and Python to Swift, I've found myself lacking an easy way to deal with the file system. Sure, FileManager has a quite nice API, but it can be quite cumbersome to use because of its string-based nature, which makes simple scripts that move or rename files quickly become quite complex.

So, I made Files, to enable me to quickly handle files and folders, in an expressive way. And, since I love open source, I thought - why not package it up and share it with the community? :)

Questions or feedback?

Feel free to open an issue, or find me @johnsundell on Twitter.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].