title: OSX: Moving a file from Trash to its previous location programmatically
body: <p>OSX: Is there a way to restore a file from trash programmatically? I tried using NSFileManager but it results in error</p>
  
  <pre><code>NSFileManager* fm=[NSFileManager defaultManager];
  NSError* err;
  [fm copyItemAtPath:@"/Users/xyz/.Trash/abc.txt" toPath:@"/Users/xyz/Desktop/" error:&amp;err];
  NSLog(@"err:%@",err)
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>Error Domain=NSCocoaErrorDomain Code=516 "“abc.txt” couldn’t be copied to “Desktop” because an item with the same name already exists." UserInfo={NSSourceFilePathErrorKey=/Users/xyz/.Trash/abc.txt, NSUserStringVariant=(
  Copy), NSDestinationFilePath=/Users/xyz/Desktop, NSFilePath=/Users/xyz/.Trash/abc.txt, NSUnderlyingError=0x610000041560 {Error Domain=NSPOSIXErrorDomain Code=17 "File exists"}}
  </code></pre>