I came across another solution by using Automator.
Open Automator
Select Services
Select Utilities -> Run Shell Script (drag it into the window on the right)
Top bar above code window.
Service receives: no input in Finder
Add the following code to show hidden files
status=`defaults read com.apple.finder AppleShowAllFiles`
if [ $status == true ];
then
defaults write com.apple.finder AppleShowAllFiles false
else
defaults write com.apple.finder AppleShowAllFiles true
fi
killall Finder
Save the script.
Make a shortcut
Go to System Preferences -> Keyboard -> Shortcuts -> Services and find the Services you made showing hidden files. There might be a shortcut there if so test it out. If there is not shortcut there then add shift+cmd+. (period) as the shortcut.
To show hidden files use the shortcut: shift+cmd+. (period).
To hide the files use the same shortcut again.
OR click the desktop and go to in the top menu: Finder -> Services -> name of file to show hidden files. First time to show the files and second time to hide them.
To delete Services scripts.
Go to your hard drive -> user name -> Library -> Services -> and there you will see the Services Automator scripts.
Resources used:
https://discussions.apple.com/message/29357134#29357134
How to delete Automator services.
https://www.youtube.com/watch?v=kaVHwhau1M4
Here is a tutorial that I made: https://www.easywebdesigntutorials.com/easily-show-hide-hidden-files-on-the-mac/