Script to unzip file to user Library

tcunningham
New Contributor II

I'm trying to write a script to unzip a zip file from tmp to a user Library, the exact path is:

unzip /tmp/MicrosoftChartTemplates.zip -d /Users/USERNAME/Library/Group Containers/UBF8T346G9.Office/User Content/Chart Templates

The issue seems to be spaces, like for "Group Containers". From what I understand you need quotes, but that doesn't seem to work either. Once the file is in that folder I need to unzip it to that location. Any help would be much appreciated. Also, a DMG is not an option since we will be updating these files regularly and would like to only update the zip file and the not the entire package. This wasn't my decision, just what I have to work with.

Thanks to all who take the time to reply.

2 ACCEPTED SOLUTIONS

Corey_Nechkash
New Contributor III

I think you're missing some syntax. Some of these folders have a ".localized" that follows the folder name. 

This seemed to work for me:

unzip /tmp/MicrosoftChartTemplates.zip -d "/Users/USERNAME/Library/Group Containers/UBF8T346G9.Office/User Content.localized/Chart Templates.localized/"

or you can do it without the quotes too:

unzip /tmp/MicrosoftChartTemplates.zip -d /Users/USERNAME/Library/Group\ Containers/UBF8T346G9.Office/User\ Content.localized/Chart\ Templates.localized/

 

Hopefully that works for you,

Corey

View solution in original post

tcunningham
New Contributor II

Thank you to everyone who responded! @Corey_Nachkash your solution got me there, I appreciate the help! Here is the script for anyone who might need it.

#!/bin/sh

 

localUsers=$( dscl . list /Users UniqueID | awk '$2 >= 501 {print $1}' | grep -v admin )

 

for userName in "$localUsers"; do

unzip /tmp/MicrosoftChartTemplates.zip -d /Users/tcunningham/Library/Group\ Containers/UBF8T346G9.Office/User\ Content.localized/Chart\ Templates.localized/

done

 

View solution in original post

5 REPLIES 5

sgiesbrecht
Contributor III

have you tried single quote ( ' ) instead of the quote ( " )? 

Corey_Nechkash
New Contributor III

I think you're missing some syntax. Some of these folders have a ".localized" that follows the folder name. 

This seemed to work for me:

unzip /tmp/MicrosoftChartTemplates.zip -d "/Users/USERNAME/Library/Group Containers/UBF8T346G9.Office/User Content.localized/Chart Templates.localized/"

or you can do it without the quotes too:

unzip /tmp/MicrosoftChartTemplates.zip -d /Users/USERNAME/Library/Group\ Containers/UBF8T346G9.Office/User\ Content.localized/Chart\ Templates.localized/

 

Hopefully that works for you,

Corey

shannon_pasto
Contributor

Perhaps installing them into the system would be better? Not sure if they'd work with charts but might be easier.

I install powerpoint and word templates to 

/Library/Application Support/Microsoft/Office365/User Content.localized/Templates.localized

Anonymous
Not applicable

if there are spaces in a path, you will have to "escape" them like in the second example from Corey_Nachkash. This should work

tcunningham
New Contributor II

Thank you to everyone who responded! @Corey_Nachkash your solution got me there, I appreciate the help! Here is the script for anyone who might need it.

#!/bin/sh

 

localUsers=$( dscl . list /Users UniqueID | awk '$2 >= 501 {print $1}' | grep -v admin )

 

for userName in "$localUsers"; do

unzip /tmp/MicrosoftChartTemplates.zip -d /Users/tcunningham/Library/Group\ Containers/UBF8T346G9.Office/User\ Content.localized/Chart\ Templates.localized/

done