Monday, December 10, 2018

Automator script for folder structure in right click menu.

Automator script for folder structure in right click menu.

I had a client that works with graphics and requires an easy way to create a folder standard folder structure. This ensures that all client jobs are the same structure. This task can easily be used to create a folder structure with files and resources.


To create this script I used Automator, open Automator and start a new workflow. 



Select Service and click 'choose'.

This will open a blank workflow.


From here the possibilities are endless, but we want to create folders. 

In the left pane, under Library select Utilities. Inside utilities double click on 'Run Shell Script'. This is how we will be creating the folder structure. 


We will be using simple commands to make the structure as we desire. The commands we will be using are 'cd' and 'mkdir'. These two commands will allow us to accomplish everything we need. 

*Note* one of the tricky parts of this script is getting it to run in the correct folder. To accomplish this we will set the variable for the current folder and then move to it.

#Set current directury as current path and move to it
current_path=$(dirname "$1")
cd "$current_path"

Now that we have the script running in the correct folder we can start to make our structure. 
For this example, I will be using generic folder names, Folder#.  

#create first upper lvl folder
mkdir Folder1

With the initial folder created we can build in that folder.

#Folders inside the first folder
mkdir Folder1/Folder2
mkdir Folder1/Folder3

That is the basis of how this script works, create a folder and then create more inside it. If we need more folders in the structure we can add folders into it. 

#create Folders inside the second folder
mkdir Folder1/Folder2/Folder4
mkdir Folder1/Folder2/Folder5
mkdir Folder1/Folder2/Folder6

The only rule here is you have to create the upper-level folders before you can put the lower-level folders inside.  When you put it all together it should look something like this, but the folders should be named properly. 


#Set current directury as current path and move to it
current_path=$(dirname "$1")
cd "$current_path"

#Create first level folder
mkdir Folder1

#Create folders inside the first folder
mkdir Folder1/Folder2
mkdir Folder1/Folder3

#Create folders inside the second folder
mkdir Folder1/Folder2/Folder4
mkdir Folder1/Folder2/Folder5
mkdir Folder1/Folder2/Folder6

After the script has been created and saved we need to place it somewhere to make it available for use. If you would like this to just be available to the user account only, just double-click on the workflow file and install it. 

If you would like to action available to any user on the machine it needs to be placed into the  /Library/Services folder. This folder may not exist on your Mac, if it does not then create it and place the workflow file inside.



Now when you right click on a file or folder you will have a services section at the bottom that contains your new custom script. You can see here our action is called Folder-Creator. click this and it will create the folder structure we laid out in Automator. 




This menu action will be available for all users that login to this machine. You can open and edit this task as you need, or add in other actions that suit your structure. 

Please comment if you found this useful or have any questions.


Wednesday, October 17, 2018

Show Shared Calendars in iCal. Mac Calendar.

I recently had a client switch to exchange, much better service right?

There are always problems with switching...

We had a fairly straightforward switch, using GoDaddy 365 services. Exported the Calendars from the iCloud accounts and Importing them into the Exchange account.



First small(ish) issue was that Exchange cannot handle some of the events that are repeating forever. The client was very understanding and was ok with recreating these events. There were also other events information for the events that were not specified and was unable to be imported.


These two problems on their own could cause a significant headache for someone migrating to Exchange with old or large calendars. However, I had the luxury of not having to worry about it... This time.

Now to the heart of the issue you are here for. Shared calendars and delegates.

After I had migrated the calendar events and ignored the warning messages I moved on to sharing the calendars and settings up delegates.

When typing the name of the delegate the field would not auto-populate with the email address from the domain. It was showing random names of people I knew or other clients... This was puzzling.
I thought this was very weird but wondered where and why these names were popping up. I know they couldn't be on the client's exchange server/domain so I was very confused.



I think though maybe it was pulling names from my contacts app. I typed in a few names of people I went to college with and sure enough they showed up. The other odd thing is I could select them as a delegate but they would have no permissions. So I added the delegates to the Contacts app.


This worked! After adding the desired delegate to the contacts app on my local machine they appeared in the delegation section on iCal, which is supposed to look at the Exchange server, and not only did they show up, they were given proper permissions for accessing the shared calendars!




That's it, That's the entire solution. All that's left to do is check the box to Show. Just had to add them to the local machines contacts...... Of course, there was a bit of setting up the shared calendars in the back end but if you made it this far I don't think that was your problem.

I hope I was able to help you solve any issues you were having with delegation setup. Please leave a comment!


Tuesday, October 24, 2017

SOLVED: Outlook for mac "outlook can't upgrade your database"

An actual solution to fix the outlook database.
Error: Outlook can't upgrade your database.

Problem: Like a lot of you, I ran into this issue at the worst time possible. I had applied an update to the Office Suite to fix an Excel issue and broke Outlook... My client then tells me she is leaving out of town tomorrow and needs this machine to be working with all her emails accessible by the morning. 

No problem, I set up the account again in a new profile and were good, right? No. 

"Where are all the folders that were On My Mac!??" she says with a panic in her voice. 

I create another new profile and import the one that won't upgrade. The import process goes well and emails and accounts show up but still no "On My Mac" folders recovered. 

Time Machine! I knew time machine would work! 
Enter time machine and restore the profile from last week. Set it as default and try to open; No luck. "Outlook Can't upgrade your database". Back to square one. 

I finally came across a small post on SpiceWorks with someone who actually fixed the issue by forcing outlook to rebuild the database, I will show you how to do this today. 

Solution: The fix is unfortunately quite simple. Go to where the mail database is stored, 
~/Library/Group Containers/UBF8T346G9.Office/Outlook/Outlook 15 Profiles/Main Profile/Data (on mac) and delete or simply move the "Outlook.sqllite" file. Always have backups first. 



Now, assuming you have not changed your default profile, simply open outlook and you should be prompted that there is a problem and outlook needs to rebuild. If you did change your profile, change it back to 'Main Profile'.

This can take a while, mine took ~1hr. After it was done outlook launched and asked to download a bunch of fonts. After downloading, all the accounts and emails were recovered and the "on my mac" section had all the emails and folders the user had setup.

This fix worked for me, I hope it can work for some of you!

Reference: michaelhof : https://community.spiceworks.com/topic/1274738-office-2016-for-mac-manual-database-identity-rebuild  

Monday, April 10, 2017

Solved, Cannot add or change bookmarks in Firefox, Mac.

Cannot add or change bookmarks in Firefox

If you are having the problem of firefox not allowing you to add a bookmark, try the following steps they worked for me. I tried the steps laid out by Mozilla located Here , with little success.

I am using FF Version 51.0, here is what I did.

Locate the users Preferences (HD/Users/UserName/Library/Preferences) folder and open it.

Inside that folder will be .plist files that need to be deleted. Delete any .plist file with mozilla or firefox in the name. These will be recreated when the application opens next.

Open Application support folder (HD/Users/UserName/Library/Application Support). In here will be a folder for Mozilla or Firefox, there may even be a folder for each. Delete the folder(s). 

Launch firefox again, go through the initial setup and see all the problems go away. 

**Note: This will erase all settings and content in firefox. bookmarks, passwords, history, etc...

Tuesday, March 7, 2017

Move or Delete files with a log. Windows, .BAT

Below are 2 .bat files. One moves files and creates a log of the files moved and the other deletes the files and creates a log.
The way I use this is the backup files go into a folder for offset backups and get copied off site, they then get moved into another folder to store for a longer time and finally deleted after a # of days to preserve space.

MOVE

ECHO OFF

REM Author Daniel Gallant
REM Date Nov, 2016

setlocal ENABLEDELAYEDEXPANSION

REM This program will create a text document with the name of the files older then 'numDays' days, and will then move those files older then 'numDays' days to 'backupArchive'.


REM Change these to:
set "backUpPath=C:\Users\Public\Pictures\Sample Pictures3" REM Specify the folder to move files from
set "logPath=C:\Users\Public\logs" REM Specift the folder to send log file to
set "numDays=2" REM Specify number of days old the files are before they are moved
set "backupArchive=C:\Users\Public\Pictures\archive" REM This is where the files are moved to
set "today=!date:/=-!" REM *DO NOT CHANGE* This is a variable to set todays date in the log file name


REM This lists the files and puts them into a .txt for review after Move.
REM -p= path to backup files; -s= include subdirectiries; -m=type of file to search for; /D=num of days, - means old; /C rum the command in "" from cmd
forfiles -p "%backupPath%" -s -m *.* /D -%numDays% /C "cmd /c echo @path" >> "%logPath%\!today!_Backups-Moved.txt"


REM This command moves the files older then 'numDays'.

forfiles -p "%backupPath%" -s -m *.* /D -%numDays% /C "cmd /c move @path %backupArchive%"



DELETE

@ECHO OFF
REM Author Daniel Gallant
REM Date Nov, 2016

setlocal ENABLEDELAYEDEXPANSION

REM This program will create a text document with the name of the files older then 'numDays' days, and will then delete those files older then 'numDays' days..


REM Change these to:
set "backUpPath=C:\Users\Christian\Pictures" REM Specify the folder to delete files from
set "logPath=C:\Users\Public" REM Specift the folder to send log file to, Folder must be created
set "numDays=30" REM Specify number of days old the files are before they are moved
set "today=!date:/=-!" REM This is a variable to set todays date in the log file name
REM This lists the files and puts them into a .txt for review after delete.
REM -p= path to backup files; -s= include subdirectiries; -m=type of file to search for; /D=num of days, - means old; /C rum the command in "" from cmd
forfiles -p "%backupPath%" -s -m *.* /D -%numDays% /C "cmd /c echo @path" >> "%logPath%\!today!_Backups-Deleted.txt"


REM This command deletes the files older then /D #.

REM forfiles -p "%backupPath%" -s -m *.* /D -%numDays% /C "cmd /c /q del @path"   <- This is for deleting the files.

Thursday, December 8, 2016

enable or disable team viewer in Terminal, Mac

If trying to kill TeamViewerHost.app make sure to specify full name. If unsure type "Team" and hit 'tab', this will autofill the name of the app. This works best when trying to remote into a computer but TV is now working, SSL into the computer and run these commands. *Note*TeamViewerHost.app and TeamViewer.app are different.*

ON: open -g -a /Applications/TeamViewer.app
And to gracefully quit instead of kill-ing:
OFF: osascript -e 'quit app "TeamViewer.app”

Getting Detailed S.M.A.R.T status on Mac

Below is a small, simple step by step to install smartctl which gives detailed information about internal hard drives and both HDD and SSD.

To install smartctl

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

brew install smartmontools

find /usr -name smartctl

cd /Users/admin/

mkdir .bin

cd /.bin

cd /Users/admin/.bin/

mkdir shell-tools

cd shell-tools/

mkdir smartctl

find /usr -name smartctl

*Check the first location, it will not be the same. This is from the find command above.*
ln -s /usr/local/Cellar/smartmontools/6.5/bin/smartctl /Users/admin/.bin/shell-tools/smartctl/smartctl

nano /Users/admin/.bash_profile
\-> add: PATH=“$PATH:$HOME/.bin/shell-tools/smartctl”

*Close Terminal App and reopen. 
Now you can use the smartctl command. 
Ex:
df

smartctl -a disk1