forked from tangqiaoboy/xcode_tool
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvertImage.sh
More file actions
executable file
·45 lines (38 loc) · 940 Bytes
/
convertImage.sh
File metadata and controls
executable file
·45 lines (38 loc) · 940 Bytes
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
#! /bin/bash
# print usage
usage() {
cat << EOF
Usage:
convertImage.sh <src directory> <dest directory>
EOF
}
if [ $# -ne 2 ]; then
usage
exit 1
fi
SRC_DIR=$1
DEST_DIR=$2
# check src dir
if [ ! -d $SRC_DIR ]; then
echo "src directory not exist: $SRC_DIR"
exit 1
fi
# check dest dir
if [ ! -d $DEST_DIR ]; then
mkdir -p $DEST_DIR
fi
for src_file in $SRC_DIR/*.* ; do
echo "process file name: $src_file"
# 获得去掉文件名的纯路径
src_path=`dirname $src_file`
# 获得去掉路径的纯文件名
filename=`basename $src_file`
# 获得文件名字(不包括扩展名)
name=`echo "$filename" | cut -d'.' -f1`
# remove @2x in filename if there is
name=`echo "$name" | cut -d"@" -f1`
# 获得文件扩展名
extension=`echo "$filename" | cut -d'.' -f2`
dest_file="$DEST_DIR/${name}.${extension}"
convert $src_file -resize 50% $dest_file
done