forked from daveabbott/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvertPath.sh
More file actions
executable file
·66 lines (59 loc) · 1.7 KB
/
Copy pathconvertPath.sh
File metadata and controls
executable file
·66 lines (59 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
# Converts filepaths between Linux, Mac and Windows depending on where I'm working.
# export STUDIO="pixel"
source ~/.bash_profile
# TEST PATHS
# Z:\ACTIVE\KMART - August Living 18\Projects\05 Shots
# /Volumes/MegaRAID/ACTIVE/KMART - August Living 18/Projects/05 Shots
# /mnt/MegaRAID/active/KMART - August Living 18/Projects/05 Shots
echo Converting path for location: $STUDIO
echo ----------------
if [ "$STUDIO" == "home" ]; then
winPath="-----------"
macPath="~/Resilio Sync"
linPath="/mnt/kabbalah/active"
elif [ "$STUDIO" == "airbag" ]; then
winPath="L:\ACTIVE"
macPath="/Volumes/L/ACTIVE"
linPath="/mnt/airbag/L/active"
elif [ "$STUDIO" == "pixel" ]; then
winPath="Z:\ACTIVE"
macPath="/Volumes/MegaRAID/ACTIVE"
linPath="/mnt/MegaRAID/active"
else
echo $STUDIO unknown location
exit 1
fi
function convertPath {
if [ "$(uname)" == "Darwin" ]; then # Get clipboard contents
cb=`pbpaste`
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
cb=`xclip -o`
fi
echo input: "$cb" # print contents as input
if [[ "$cb" == /V* ]]; then # convert from mac
LIN=${cb/"$macPath"/"$linPath"}
MAC=$cb
WIN=${cb/"$macPath"/"$winPath"}
elif [[ "$cb" == /m* ]]; then # convert from lin
MAC=${cb/"$linPath"/"$macPath"}
LIN=$cb
WIN=${cb/"$linPath"/"$winPath"}
elif [[ "$cb" == *:* ]]; then # convert from win
LIN=${cb/"$winPath"/"$linPath"}
MAC=${cb/"$winPath"/"$macPath"}
WIN=$cb
else
LIN="invalid path"
MAC="invalid path"
WIN="invalid path"
fi
LIN=${LIN//\\//} # flip slashes for win
MAC=${MAC//\\//}
WIN=${WIN////\\}
echo #blank
echo Lin: "$LIN" # print conversion
echo Mac: "$MAC"
echo Win: "$WIN"
}
convertPath