Created
September 18, 2012 07:14
-
-
Save umezo/3741739 to your computer and use it in GitHub Desktop.
convert path between ms shared folder and samba url
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function convert_smb_url() { | |
local file_path='' | |
if [ -n "$1" ] ; then | |
file_path=$1 | |
else | |
file_path=`print -R $(pbpaste)` | |
fi | |
if [ -n $file_path ] ; then | |
local prefix=`echo $1|egrep "^smb://" -o` | |
local direction='' | |
local sed1='' | |
local sed2='' | |
print -R convert $file_path | |
# case samba to win | |
if [ -n "$prefix" ] ; then | |
direction="mac–>win" | |
sed1='s/\//\\/g' | |
sed2='s/smb://' | |
# case win to samba | |
else | |
direction="win->mac" | |
sed1='s/\\/\//g' | |
sed2='s/^/smb:/' | |
fi | |
#echo $direction | |
#print -R "$file_path" | sed -e "$sed1" -e "$sed2" | |
print -R "$file_path" | sed -e "$sed1" -e "$sed2" | pbcopy | |
#print convert result will be copied into clipboard | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment