多渠道打包 之 批量重名文件名
来源:互联网 发布:sql server下载版安装 编辑:程序博客网 时间:2024/05/22 15:59
针对360加固后文件重命名
原始文件名:android_v2.2.3_app_223_1_jiagu_sign.apk
输出结果:android_v2.2.3_baidu.apk
public class Main { private static String IN_FILE_PATH = "F:\\ApkVersion\\2.2.3\\";//目标文件地址 private static String OUT_FILE_PATH = "F:\\ApkVersion\\2.2.3\\";//输出文件地址 private static String APP_VERSION = "v2.2.3";//版本号 //渠道数组:顺序与加固渠道码一致 private static String[] channels = new String[]{ "baidu", "360", "qq", "oppo", "vivo"}; public static void main(String[] args) { // write your code here //批量重命名文件 updateFileName(IN_FILE_PATH,OUT_FILE_PATH); } private static void updateFileName(String dirPath,String outPath) { File file = new File(dirPath); //判断文件目录是否存在,且是文件目录 if (file.exists() && file.isDirectory()) { //获取文件列表 File[] childFiles = file.listFiles(); String path = file.getAbsolutePath(); System.out.print("path =" + path); for (File childFile : childFiles) { //如果是文件 if (childFile.isFile()) { String oldName = childFile.getName(); System.out.print("\noldName =" + oldName); String[] splitResult = oldName.split("_"); String newName; for (int i = 0; i < splitResult.length; i++) { System.out.print("\nsplitResult =" + splitResult[i]); } int num = Integer.valueOf(splitResult[4]); newName = "android_" + APP_VERSION + "_" + channels[num - 1] + ".apk"; ifDirExists(new File(outPath)); boolean update = childFile.renameTo(new File(OUT_FILE_PATH + newName)); if (update) { System.out.print("\n第" + num + "个文件重命名成功" + "\n结果: " + childFile.getName()); } } System.out.print("\n文件重命名成功" + "\n结果: " + childFile.getName()); } } } //判断文件夹是否存在 public static void ifDirExists(File dirFile) { if (dirFile.exists()) { if (dirFile.isDirectory()) { System.out.println("\ndir exists"); } else { System.out.println("\nthe same name file exists, can not create dir"); } } else { System.out.println("dir not exists, create it ..."); dirFile.mkdir(); } }}
阅读全文
0 0
- 多渠道打包 之 批量重名文件名
- Ant批量多渠道打包
- 多渠道批量打包
- Android多渠道批量打包
- Unity3d开发之 多渠道批量打包(四)
- Android:Ant 批量多渠道打包
- python: android批量多渠道打包
- android Ant 批量多渠道打包!
- android ant 多渠道批量打包
- apk多渠道批量打包memo
- android Ant 批量多渠道打包
- android ant 多渠道批量打包
- android Ant 批量多渠道打包
- python: android批量多渠道打包
- Android Gradle多渠道批量打包
- gradle批量打包(非多渠道打包)
- 递归批量修改重名文件下的文件名
- android Ant 批量多渠道打包 总结!
- 动态修改桌面应用图标
- 设计模式之简单单例设计模式
- Android开发:Android 按2次back键程序才退出
- 16:矩阵剪刀石头布(1.8编程基础之多维数组)
- Floyd算法优化
- 多渠道打包 之 批量重名文件名
- BZOJ2597: [Wc2007]剪刀石头布
- Unity UI系统-UGUI简介
- cocos2dx 3.10 网狐土豪金版PC+手机端棋牌平台搭建
- HttpClient 学习笔记
- 用visualVM监控java进程
- 大数据整理笔记
- 欢迎使用CSDN-markdown编辑器
- 初识Apache Storm