Last active
August 29, 2015 14:15
-
-
Save Aidan-Huang/83aab7d74357a16cd32c to your computer and use it in GitHub Desktop.
copy dir files for EnglishPod
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Cocoa | |
let folderPath = "/Users/admin/Downloads/1-30" | |
let newPath = "/Users/admin/tmp/" | |
let fileManager = NSFileManager.defaultManager() | |
let enumerator:NSDirectoryEnumerator = fileManager.enumeratorAtPath(folderPath)! | |
while let element = enumerator.nextObject() as? String { | |
if element.hasSuffix("dg.mp3") { | |
var fullElementPath = folderPath.stringByAppendingPathComponent(element) | |
println(fullElementPath) | |
let destPath = newPath.stringByAppendingPathComponent(element.lastPathComponent) | |
var err: NSError? | |
if NSFileManager.defaultManager().copyItemAtPath(fullElementPath, toPath: destPath, error: &err) { | |
println("\(fullElementPath) file added to the folder.") | |
} else { | |
println("FAILED to add \(fullElementPath) to the folder.") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment