Terminal command to change desktop wallpaper not working
I recently made a program that changed my desktop wallpaper depending on the time of the day. It worked by entering a terminal command that looked something like this:
osascript -e 'tell application "Finder" to set desktop picture to "/path/to/file.jpg" as POSIX file'
It was working fine, until recently. Now when I enter the command to set "file.jpg", it works and sets it as my wallpaper as it's supposed to, but when I replace it with a new image of the same name and path, the command sets my wallpaper to the original image of that name. When I went to change my wallpaper through System Preferences, it showed in the preview box that my new image was set, even though it wasn't. Am I doing something wrong or is there a problem with my Mac?
MacBook Pro with Retina display, OS X El Capitan (10.11.5)