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)

Posted on Jul 18, 2016 10:58 AM

Reply
4 replies

Jul 19, 2016 6:29 AM in response to VikingOSX

It still does not work. The command works perfectly fine only the first time I use it.

User uploaded file

But when I enter it again with a new but similarly named photo it changes it to the original one.

User uploaded file

As you can see, the new image appears in the preview box in System Preferences but the wallpaper is still the original.

User uploaded file

Also, sometimes when I check through system preferences, my wallpaper changes to blue and nothing is shown in the preview.

User uploaded file

If I were to change my wallpaper through System Preferences, it would work fine, but if I wanted to use the command sometime in the future with another "file.jpg", it will set it to the 'ducks' wallpaper shown in the pictures.

Is this supposed to happen?

Jul 19, 2016 3:52 PM in response to MLFusco

We are using identical syntax, and the only difference is that you are attempting to set wallpaper with different images bearing identical filenames from the same filesystem (Desktop) location. When I do this, I get the same result as you.


If you don't adopt this practice, and use unique images and names, then the syntax is repetitiously reliable as I previously reported.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Terminal command to change desktop wallpaper not working

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.