@sudhan Completely untested, but something like rm -rf /Users/user/Music/* !('LoopsDatabaseV09.db')
should work.
Hi @dan-snelson
Thank you for your instant reply. I tried your script and unfortunately, it's not working for us.
Please see the attached image.
Thank you once again.
I would set the system immutable flag for LoopsDatabaseV09.db with "sudo chflags simmutable $pathToFile". With that set even a "sudo rm -rf $pathToFile" will fail, and the file and its parent directories will survive. The downside is that the rm will create an error message.
A "sudo chflags nosimmutable $pathToFile" is needed to make the file 'removable' again.
@sudhan Try this out.
First delete the files except the one you want to keep:
find /Users/user/Music ! -name "LoopsDatabaseV09.db" -type f -exec rm "{}" ;
Then delete the empty directories recursively:
find /Users/user/Music -type d -exec rmdir -p {} ;
This should leave LoopsDatabaseV09.db in the same directory it was originally located.
Hi @mschroder ,
Thank you for getting back. I apologies, but what you are suggesting it bit beyond my basic knowledge of JAMF. But thank you anyway for your suggestion.
Hi @ryan.ball ,
IT WORKED!!!!!!!!! Thank you also for getting back. Really appreciate your help. Hope this is also helpful for anyone else who's having the same issue.
Best wishes,
Sudhan
Hi @ryan.ball ,
IT WORKED!!!!!!!!! Thank you also for getting back. Really appreciate your help. Hope this is also helpful for anyone else who's having the same issue.
Best wishes,
Sudhan
Why are you trying to do this? The Loops should be a shared resource available to all users. It seems like you have multiple accounts that might be downloading multiple loops into personal accounts. The better move would be to move all loops into the shared loops directory.
@sudhan Try this out.
First delete the files except the one you want to keep:
find /Users/user/Music ! -name "LoopsDatabaseV09.db" -type f -exec rm "{}" ;
Then delete the empty directories recursively:
find /Users/user/Music -type d -exec rmdir -p {} ;
This should leave LoopsDatabaseV09.db in the same directory it was originally located.
Giving error.
find /Users ! -name "administrator" -type d -exec rm "{}" ;
find: -exec: no terminating ";" or "+"
Giving error.
find /Users ! -name "administrator" -type d -exec rm "{}" ;
find: -exec: no terminating ";" or "+"
Mine is also giving error:
1:233: execution error: find: -exec: no terminating ";" or "+"
find: -exec: no terminating ";" or "+" (1)
Here is my script
#!/bin/bash
lastUser=`defaults read /Library/Preferences/com.apple.loginwindow lastUserName`
find /Users/$lastUser/Desktop ! -name "1.jpg" -type f -exec rm "{}" ;
find /Users/$lastUser/Desktop -type d -exec rmdir -p {} ;