-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathmake_from_blender291_addons.scr
146 lines (109 loc) · 3.29 KB
/
make_from_blender291_addons.scr
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
echo "This script needs revising!!! Do not use for now!!"
exit 1
##############################
echo "This will overwrite 'local' copies and those in Blender 2.7!!"
echo "Are you sure? (y=continue)"
read REPLY
if [ "$REPLY" != 'y' ]
then
echo "Aborted!"
exit 1
fi
#=====================================================================================================================
function convert_to_27()
{
SOURCEDIR=$1
DESTDIR=$2
ZIP="c:/program files/7-zip/7z.exe"
mv "$DESTDIR" "../old/$DESTDIR.`date +%Y%m%d.%H%M%S`"
if [ "$?" -ne 0 ]
then
echo "Failed to backup old version"
echo "Press ENTER to continue"
read REPLY
fi
mkdir "$DESTDIR"
if [ "$?" -ne 0 ]
then
echo "Failed to create new empty directory"
exit 3
fi
for file in `ls -1 $SOURCEDIR`
do
if [ ! -z "`echo $file|grep '\.py$'`" ]
then
#It's a 'py' file
#Convert 'XXXX[n]: bpy.props...' to 'XXXX = bpy.props...'
cat $SOURCEDIR/$file |sed 's/\([a-z][0-9]*\): bpy.prop/\1 = bpy.prop/' |sed 's/2, 80, 0/2, 76, 0/' >$DESTDIR/$file
else
#Copy it
cp -rfd "$SOURCEDIR"/"$file" "$DESTDIR"
fi
done
}
#=====================================================================================================================
#for addon in MathsExpressionLiteBlender Smoke2EXR Fluid2EXR
for addon in Fluid2EXR
do
BLENDER28SOURCE="C:/Users/Rich/AppData/Roaming/Blender Foundation/Blender/2.91/scripts/addons/${addon}28"
echo -e "\n\nAdd-on '$addon' : Copy from '$BLENDER28SOURCE' and overwrite 'local' copy?"
read REPLY
if [ "$REPLY" = "y" ]
then
echo "Copying..."
sleep 2
if [ ! -d "${addon}28" ]
then
mkdir "${addon}28"
fi
for file in `ls -1 "$BLENDER28SOURCE"|grep '\.py$'`
do
cp "$BLENDER28SOURCE/$file" "${addon}28"
done
for file in `ls -1 "$BLENDER28SOURCE"|grep '\.txt$'`
do
cp "$BLENDER28SOURCE/$file" "${addon}28"
done
else
continue
fi
echo -e "\n\nConvert '$addon' 28 version to 27?"
read REPLY
if [ "$REPLY" = "y" ]
then
convert_to_27 "${addon}28" "${addon}27"
fi
echo -e "\n\nRe-build '$addon' ZIP files?"
read REPLY
if [ "$REPLY" = "y" ]
then
echo "Rebuilding..."
for module in "${addon}27" "${addon}28"
do
echo "$module"
rm -f "$module.zip"
"$ZIP" a "$module.zip" $module
done
ls -l *zip
fi
echo -e "\n\nUnpack '$addon' to Blender 2.79 addons?"
read REPLY
if [ "$REPLY" = "y" ]
then
# Unzip to 2.79 blender addons, with overwrite mode of 'all'
"$ZIP" x -aoa -o"c:/Users/rich/AppData/Roaming/Blender Foundation/Blender/2.79/scripts/addons" "${addon}27.zip"
fi
echo -e "\n\nRename ZIPs based on version?"
read REPLY
if [ "$REPLY" = "y" ]
then
for file in ${addon}28 ${addon}27
do
VERSION="`grep '"version":' $file/__init__.py|sed 's/.*(//'|sed 's/).*$//'|tr -d ' '|tr ',' '.'`"
echo "$file ($VERSION)"
mv $file.zip ${file}_${VERSION}.zip
done
fi
echo "Done"
done
exit 0