I am writing a bash script for an automator service that will take a Windows directory location and change it to Mac and open a finder window. It's working except for when it hits folders with spaces. I have put in to remove them but it won't work on anything with spaces still. I must have made some sort of syntax mistake.
sed -e 's:\\\\fmg_cifs1\\Dept_Shares:/Volumes/Dept_Shares:' -e 's: :\ :g' -e 's:\\:/:g' | pbcopy
TAG=$(pbpaste)
cd $TAG; open .
This is almost certainly all you have to change:
cd "$TAG"
Quoting fixes everything!
Do you need to use pbcopy
and pbpaste
and a variable?
cd "$(sed -e 's:\\\\fmg_cifs1\\Dept_Shares:/Volumes/Dept_Shares:' -e 's: :\ :g' -e 's:\\:/:g')"
As Jonathan pointed out, some of the sed
command is unnecessary. Of course, something needs to be fed to sed
. This may be all you need:
cd "$(echo "$dir" | sed -e 's:\\\\fmg_cifs1\\Dept_Shares:/Volumes/Dept_Shares:')"