<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSString/deletingPathExtension",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSString(py)stringByDeletingPathExtension"
  },
  "title" : "deletingPathExtension"
}
-->

# deletingPathExtension

A new string made by deleting the extension (if any, and only the last) from the receiver.

```
var deletingPathExtension: String { get }
```

## Discussion

A new string made by deleting the extension (if any, and only the last) from the receiver. Strips any trailing path separator before checking for an extension. If the receiver represents the root path, it is returned unaltered.

The following table illustrates the effect of this method on a variety of different paths:

|Receiver’s String Value|Resulting String|
|-----------------------|----------------|
|“`/tmp/scratch.tiff`”  |“`/tmp/scratch`”|
|“`/tmp/`”              |“`/tmp`”        |
|“`scratch.bundle/`”    |“`scratch`”     |
|“`scratch..tiff`”      |“`scratch.`”    |
|“`.tiff`”              |“`.tiff`”       |
|“`/`”                  |“`/`”           |

Note that attempting to delete an extension from `@".tiff"` causes the result to be `@".tiff"` instead of an empty string. This difference is because a file named `@".tiff"` is not considered to have an extension, so nothing is deleted. Note also that this method only works with file paths (not, for example, string representations of URLs).

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)