How do I reliably get the file name of the current background picture? [duplicate]
Try
/usr/libexec/PlistBuddy -c 'Print :Background:default:ImageFilePath' ~/Library/Preferences/com.apple.desktop.plist
You can type:
defaults write com.apple.dock desktop-picture-show-debug-text -bool TRUE;killall Dock
and this will print the complete path on the Desktop image. So viewing your desktop you'll see the file name and path.
To remove the file name from the desktop just type:
defaults delete com.apple.dock desktop-picture-show-debug-text;killall Dock
More info on this is given here.