一、bash路径中的space
#!/bin/bash
echo `pwd`
bakup=$IFS
IFS=`echo -en "\n\b"`
for i in $(find . -name "Screen*");do
new=${i// /_}
#echo ${new}
new=${new/Screen_Shot_/}
echo ${new}
mv ${i} ${new}
done
IFS=$bakup
二、大量图片切割
#!/bin/bash
path=$(cd "$(dirname "$0")"; pwd)
echo ${path}
cd ${path}
rm _2016*.png
for i in $(find . -name "*.png");do
convert $i -quality 100 -crop 480x320+88+106 ${i/2016/_2016}
done
import java.io.File;
public class What {
public static String wrap(int value) {
String item = String.valueOf(value);
int len = 4 - item.length();
StringBuffer sb = new StringBuffer();
for (int j = 0; j < len; j ++) {
sb.append("0");
}
sb.append(item);
return sb.toString();
}
public static void main(String[] args) {
// TODO Auto-generated method stub
String strPath = "/Users/max/Images/iPhone4s/";
File dir = new File(strPath);
if (!dir.exists()) {
System.out.println("Error");
return;
}
StringBuffer sb = new StringBuffer();
sb.append("#!/bin/bash\n");
sb.append("cd ").append(strPath).append("\n");
for (int i = 1; i <= 4000; i += 200) {
String from = wrap(i);
String to = wrap(i + 199);
String result = from + "~" + to;
// System.out.println(result);
String path = strPath + result;
File item = new File(path);
if (!item.exists()) {
item.mkdir();
}
for (int j = i; j <= i + 199; j ++) {
String haha = "IMG_" + wrap(j) + ".png";
File f = new File(strPath + haha);
if (!f.exists()) {
continue;
}
sb.append("mv ").append("IMG_").append(wrap(j)).append(".png ");
sb.append(result).append(File.separator).append("\n");
}
}
System.out.println(sb);
IOBridge.write(sb.toString(), new File("/Users/max/Desktop/start"));
}
}