OSS osscmd 脚本批量删除

下载阿里云OSS源码包  http://aliyunecs.oss-cn-hangzhou.aliyuncs.com/OSS_Python_API_20140509.zip

 

本地解压上传到服务器

     修改 osscmd 这个文件里面的(注意如果在服务器命令行提示

     DELETE all objects? Y/N  这句 到oss里面把注释掉  就不会有提示输入了

       # ans = raw_input("DELETE all objects? Y/N, default is N: ")

       # if ans.lower() != "y":

       #     print "quit."

       #     exit(-1)

    )   

   ID = "meL××××××××"

   KEY = "KHSYv1t××××××××××××××××××××"

 

    

 python osscmd ls  

        在云OSS建立的文件,会显示出来

       

 

oss_del.sh 

 

#!/bin/bash

#########################################

#name:zhangxiaoquan

#email:[email protected]

#date:2014-09-29

#########################################

cd /usr/local/src

for (( c=8001; c<=8888; c++ ))

do

  for ((k=1 ; k<=24; k++))

    do 

      if [ ${#k} = 2 ]; then

      echo "/jdy/old1/$c/2014/07/$k/"

      python osscmd deleteallobject oss://jdy/old1/$c/2014/07/$k/

 else

    echo "/jdy/old1/$c/2014/07/0$k/"

    python osscmd deleteallobject oss://jdy/old1/$c/2014/07/0$k/

 fi

done

 #python osscmd deleteallobject oss://jdy/old1/$c/2014/0$k/

done

 

 

启动方式  

     chmod u+x oss_del.sh

     ./oss_del.sh

 

 

 

Good Luck!

你可能感兴趣的:(OSS)