 		var dateStrings : Array<String> = []
 		for image in imageFileData {
 			var counter : Int = 1
-			let date : NSDate = image["ImageDate"] as NSDate
-			var dateString : String = "\(stringFromDate(date))_\(counter++)"
-			while (contains(dateStrings, dateString)) {
-				dateString = "\(stringFromDate(date))_\(counter++)"
-			}
-			dateStrings.append(dateString)
-			println("\(dateString)")
+			var date: NSDate {
+				get {
+					if (dateFromSelector.selectedRow == 0) {
+						return image["ImageDate"] as NSDate
+					} else {
+						return image["FileDate"] as NSDate
+					}
+				}
+			}
+			// add postfix
+			var baseName = stringFromDate(date)
+			if (postfix.stringValue != "") {
+				baseName += "_\(postfix.stringValue)"
+			}
+			// ensure name is unique if we have files with same date
+			var newFileName = "\(baseName)_\(counter++)"
+			while (contains(dateStrings, newFileName)) {
+				newFileName = "\(baseName)_\(counter++)"
+			}
+			dateStrings.append(newFileName)
+			// append original name
+			if (appendOriginalName.state == 1) {
+				var nameWOExtension : String! = image["URL"]?.lastPathComponent
+				nameWOExtension = (nameWOExtension as NSString).stringByDeletingPathExtension
+				newFileName += "(\(nameWOExtension))"
+			}
+			// add file extension
+			var ext : String! = image["FileName"]?.pathExtension
+			ext = (ext as NSString).lowercaseString
+			newFileName = "\(newFileName).\(ext)"
+			// rename
+			let oldPath : String! = image["URL"]?.path
+			println("path: \(oldPath)")
+			let basePath : String! = (oldPath as NSString).stringByDeletingLastPathComponent
+			let newPath : String = basePath.stringByAppendingPathComponent(newFileName)
+			println("newPath: \(newPath)")
+			fm.moveItemAtPath(oldPath, toPath: newPath, error: nil)
+			println("renamed to: \(newFileName)")
 		}
 	}
 	

			if (nil == source) { continue }
			imageFileData.append([
				"FileName": url.lastPathComponent,
				"ImageDate": getDateTime(source),
				"FileDate": fileCreateDate
				]
			)
			if (index < 10) {

		
	}
	
	func parseImageDate(dateStr:String, format:String="yyyy-MM-dd") -> NSDate {
		var dateFmt = NSDateFormatter()
		dateFmt.timeZone = NSTimeZone()
		dateFmt.dateFormat = format
		let date = dateFmt.dateFromString(dateStr)!
		//println("\(dateStr) -> \(date)")
