Move Images in Document Directory

please i need to move the images from folder to another folder in document directory please how can i move these images

the following my code:

let fileManager = NSFileManager.defaultManager()

do {
    let document = try fileManager.URLForDirectory(.DocumentDirectory, inDomain: .UserDomainMask, appropriateForURL: nil, create: false)
    let getFolders = try fileManager.contentsOfDirectoryAtURL(document, includingPropertiesForKeys: nil, options: .SkipsHiddenFiles)

    for folder in getFolders {
        if folder.lastPathComponent! == cell.folderNameLabel.text!   {

            for url in imageUrls {
                // ImageUrls is the array of all url which i want to move it to another folder 
          try fileManager.moveItemAtURL(NSURL(string: url)!, toURL: folder)

            }

        }
    }
}catch {
    print(error)
}

i have receive this error (fatal error: unexpectedly found nil while unwrapping an Optional value lldb)

thanks advance

Have you tried stepping through it with the debugger? My first step would be to find out which optional is nil.

Thank you for answer i will check it
But my code is right or not?

Thanks

It’s hard to say without more context - but so far I suspect url (from imageUrls) is invalid, causing the result of NSURL to be nil.

Ok thank you very much i will check it

am check it my friend and any url i can delete the image from it so in this case the url is right
but i don’t know why this problem is display to me

I grabbed your code and compiled to step through and check all the optionals are OK - the only thing I can’t verify as being OK is what comes out of imageUrls. Is it possible that most of them are fine but in some cases one isn’t?