Export with --update fails with "File exists" when two assets share the same base filename (MOV + HEIC / Live Photo pair)
bug
**Describe the bug**
I get the error `Error copying file … because an item with the same name already exists` when exporting both items into a single directory: a movie named `IMG_4402.MOV` and a photo named `IMG_4402.HEIC` that has an associated live-photo movie (`IMG_4402.mov`).
**To Reproduce**
```
osxphotos export ~/test --directory "{created.year}" --verbose --update --uuid 'F844656D-F87F-416E-A403-8AF6DA4A80A8' --uuid '4BF870D0-18B6-4AD4-8AB5-163381E80F83'
```
result:
```
osxphotos version: 0.75.2
Python version: 3.13.12 (main, Feb 3 2026, 17:53:27) [Clang 17.0.0 (clang-1700.6.3.2)]
Platform: macOS-26.2-arm64-arm-64bit-Mach-O, 26.2.0
Verbose level: 1
Using last opened Photos library: /Users/anton/Pictures/Photos Library.photoslibrary
Using osxphotos export database: version 11.0 located at /Users/anton/test/.osxphotos_export.db
Processing database /Users/anton/Pictures/Photos Library.photoslibrary/database/Photos.sqlite
Processing database /Users/anton/Pictures/Photos Library.photoslibrary/database/Photos.sqlite
Photos database version: 5001, 11.1.
Processing persons in photos.
Processing detected faces in photos.
Processing albums.
Processing keywords.
Processing photo details.
Processing import sessions.
Processing additional photo details.
Processing face details.
Processing photo labels.
Processing EXIF details.
Processing computed aesthetic scores.
Processing comments and likes for shared photos.
Processing moments.
Processing syndication info.
Processing shared iCloud library info
Done processing details from Photos library.
Exporting 2 photos to /Users/anton/test...
Export destination is on same filesystem as Photos library
Exporting IMG_4402.MOV (F844656D-F87F-416E-A403-8AF6DA4A80A8.mov) (1/2)
Exported IMG_4402.MOV to /Users/anton/test/2025/IMG_4402.MOV
Exported new file /Users/anton/test/2025/IMG_4402.MOV
Exporting IMG_4402.HEIC (4BF870D0-18B6-4AD4-8AB5-163381E80F83.heic) (2/2)
Exported IMG_4402.HEIC to /Users/anton/test/2025/IMG_4402.HEIC
Error exporting photo (4BF870D0-18B6-4AD4-8AB5-163381E80F83: IMG_4402.HEIC) as IMG_4402.HEIC: Error copying file /Users/anton/Pictures/Photos Library.photoslibrary/originals/4/4BF870D0-18B6-4AD4-8AB5-163381E80F83_3.mov to /Users/anton/test/2025/IMG_4402.mov: Error Domain=NSCocoaErrorDomain Code=516 "“4BF870D0-18B6-4AD4-8AB5-163381E80F83_3.mov” couldn’t be copied to “2025” because an item with the same name already exists." UserInfo={NSSourceFilePathErrorKey=/Users/anton/Pictures/Photos Library.photoslibrary/originals/4/4BF870D0-18B6-4AD4-8AB5-163381E80F83_3.mov, NSUserStringVariant=(
Copy
), NSDestinationFilePath=/Users/anton/test/2025/IMG_4402.mov, NSFilePath=/Users/anton/Pictures/Photos Library.photoslibrary/originals/4/4BF870D0-18B6-4AD4-8AB5-163381E80F83_3.mov, NSURL=file:///Users/anton/Pictures/Photos%20Library.photoslibrary/originals/4/4BF870D0-18B6-4AD4-8AB5-163381E80F83_3.mov, NSUnderlyingError=0xc7f422670 {Error Domain=NSPOSIXErrorDomain Code=17 "File exists"}} (photoexporter.py: 1372)
Exporting 2 photos ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00
Processed: 2 photos, exported: 1, updated: 0, skipped: 0, updated EXIF data: 0, missing: 0, error: 1
Elapsed time: 0:00:00
```
**Expected behavior**
The photo `IMG_4402.HEIC` and its associated live-photo movie should be renamed to `IMG_4402 (1).HEIC` and `IMG_4402 (1).mov`, respectively. The standalone movie `IMG_4402.MOV` should remain unchanged.
**Additional context**
This problem only arises when using the `--update` flag.
This is the run without `--update`, which works as expected:
```
❯ osxphotos export ~/test --directory "{created.year}" --verbose --uuid 'F844656D-F87F-416E-A403-8AF6DA4A80A8' --uuid '4BF870D0-18B6-4AD4-8AB5-163381E80F83'
osxphotos version: 0.75.2
Python version: 3.13.12 (main, Feb 3 2026, 17:53:27) [Clang 17.0.0 (clang-1700.6.3.2)]
Platform: macOS-26.2-arm64-arm-64bit-Mach-O, 26.2.0
Verbose level: 1
Using last opened Photos library: /Users/anton/Pictures/Photos Library.photoslibrary
Created export database /Users/anton/test/.osxphotos_export.db
Processing database /Users/anton/Pictures/Photos Library.photoslibrary/database/Photos.sqlite
Processing database /Users/anton/Pictures/Photos Library.photoslibrary/database/Photos.sqlite
Photos database version: 5001, 11.1.
Processing persons in photos.
Processing detected faces in photos.
Processing albums.
Processing keywords.
Processing photo details.
Processing import sessions.
Processing additional photo details.
Processing face details.
Processing photo labels.
Processing EXIF details.
Processing computed aesthetic scores.
Processing comments and likes for shared photos.
Processing moments.
Processing syndication info.
Processing shared iCloud library info
Done processing details from Photos library.
Exporting 2 photos to /Users/anton/test...
Exporting IMG_4402.MOV (F844656D-F87F-416E-A403-8AF6DA4A80A8.mov) (1/2)
Exported IMG_4402.MOV to /Users/anton/test/2025/IMG_4402.MOV
Exported /Users/anton/test/2025/IMG_4402.MOV
Exporting IMG_4402.HEIC (4BF870D0-18B6-4AD4-8AB5-163381E80F83.heic) (2/2)
Exported IMG_4402.HEIC to /Users/anton/test/2025/IMG_4402 (1).HEIC
Exported IMG_4402.HEIC to /Users/anton/test/2025/IMG_4402 (1).mov
Exported /Users/anton/test/2025/IMG_4402 (1).HEIC
Exported /Users/anton/test/2025/IMG_4402 (1).mov
Exporting 2 photos ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00
Processed: 2 photos, exported: 3, missing: 0, error: 0
Elapsed time: 0:00:00
```
关闭于 2026-02-15 9 条评论