Posted on 04-01-2016 02:49 PM
Does anyone know how to do folder redirection of a users Documents and Desktop folders to a folder in Google Drive if it is installed?
What I am trying to achieve is for my users when they save something to their Desktop it is backed up to Google Drive not a Network Home.
I did find this on JAMF nation and it did not work.
https://jamfnation.jamfsoftware.com/discussion.html?id=11257#responseChild66043
Posted on 04-02-2016 09:38 AM
this is what i have used in the past. but i would recommend against doing this across the board. it will create a ton of traffic going up to google drive. and things can get borked easily if something goes wrong.
i used the as a stand alone script for myself, if you want to put this in self service you will have to change the path as it will run as root and not the user
if you are going to do this make it an opt-in thing, and make sure your users know what they are getting into
#!/bin/bash
# Move local user's Documents folder into Google Drive
sudo mv $HOME/Documents $HOME/Google Drive/Documents
#Symlink the Google Drive Documents back to the local folder
ln -s $HOME/Google Drive/Documents $HOME/Documents
# Move local user's Pictures folder into Google Drive
sudo mv $HOME/Pictures $HOME/Google Drive/Pictures
#Symlink the Google Drive Pictures back to the local folder
ln -s $HOME/Google Drive/Pictures $HOME/Pictures
# Move local user's Desktop folder into Google Drive
sudo mv $HOME/Desktop $HOME/Google Drive/Desktop
#Symlink the Google Drive Desktop back to the local folder
ln -s $HOME/Google Drive/Desktop $HOME/Desktop
# Move local user's Music folder into Google Drive
sudo mv $HOME/Music $HOME/Google Drive/Music
#Symlink the Google Drive Music back to the local folder
ln -s $HOME/Google Drive/Music $HOME/Music
# Move local user's Movies folder into Google Drive
sudo mv $HOME/Movies $HOME/Google Drive/Movies
#Symlink the Google Drive Movies back to the local folder
ln -s $HOME/Google Drive/Movies $HOME/Movies
Posted on 04-04-2016 07:22 AM
Thanks for your response! I will look into this.
Posted on 04-12-2016 09:19 AM
When I try to run this in a policy, I receive back the following error - Script result: mv: rename test.student/Documents to test.student/Google Drive/Documents: No such file or directory
ln: test.student/Documents: No such file or directory
I'm guessing it's something obvious, but I'm just not seeing it. Thanks for the help!
#!/bin/bash
loggedInUser=`/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'`
# Move local user's Documents folder into Google Drive
sudo mv $loggedInUser/Documents $loggedInUser/Google Drive/Documents
#Symlink the Google Drive Documents back to the local folder
ln -s $loggedInUser/Google Drive/Documents $loggedInUser/Documents
# Move local user's Pictures folder into Google Drive
sudo mv $loggedInUser/Pictures $loggedInUser/Google Drive/Pictures
#Symlink the Google Drive Pictures back to the local folder
ln -s $loggedInUser/Google Drive/Pictures $loggedInUser/Pictures
# Move local user's Desktop folder into Google Drive
sudo mv $loggedInUser/Desktop $loggedInUser/Google Drive/Desktop
#Symlink the Google Drive Desktop back to the local folder
ln -s $loggedInUser/Google Drive/Desktop $loggedInUser/Desktop
# Move local user's Music folder into Google Drive
sudo mv $loggedInUser/Music $loggedInUser/Google Drive/Music
#Symlink the Google Drive Music back to the local folder
ln -s $loggedInUser/Google Drive/$loggedInUser $HOME/Music
# Move local user's Movies folder into Google Drive
sudo mv $loggedInUser/Movies $loggedInUser/Google Drive/Movies
#Symlink the Google Drive Movies back to the local folder
ln -s $loggedInUser/Google Drive/Movies $loggedInUser/Movies
Posted on 04-12-2016 01:36 PM
@elund your path isn't correct to the source and destination. In your example, your current path would be
test.student/Documents
when it should be
/Users/test.student/Documents
Posted on 04-12-2016 02:29 PM
@mpermann yep, it was obvious! Thanks for the help, just one of those days!!
Posted on 04-14-2017 06:44 AM
sudo mv $HOME/Documents $HOME/Google Drive/Documents
When I first tried this on my own Mac, I got this error: "Operation Not Permitted." Some searching suggested that either my Documents folder was locked, or that one of the files or folders within Documents was locked.
The fix was this:
chflags -R nouchg $HOME
Then I was able to move it.
Posted on 09-07-2017 03:16 AM
Hi,
I am trying to use the script with OneDrive but I get the operation not permitted error. Even tried chflags -R nouchg $HOME but still the same error
mv: rename /Users/karthik/Pictures to /Users/karthik/OneDrive - Karthik Inc/Pictures: Operation not permitted
Any help is appreciated. We are planning to use OneDrive to sync the home folder data.
Thanks & Regards,
Karthikeyan