Bash脚本2.0

#!/bin/bashoutput_root_dir="0723weixin"
data_root_dir="D:/data/"$output_root_dir
config_dir="config"# speckle_name="SPEACKLEIMAGE.bmp"
# ir_name="IRIMAGE.bmp"
# rgb_name="RGBIMAGE.jpg"
# config_name="config"speckle_name="speckle.bmp"
ir_name="ir.bmp"
rgb_name="rgb.jpg"
config_name="config"dir=$(ls -l $data_root_dir  |awk '/^d/ {print $NF}')
for subdir in $dir
doif [ "$subdir" != "$config_dir" ];then#echo $subdirdir1=$(ls -l $data_root_dir/$subdir |awk '/^d/ {print $NF}')for subdir1 in $dir1do#echo $data_root_dir/$subdir/$subdir1for((index=1;index<=10 ;index++))dofile_ir=$(ls -l $data_root_dir/$subdir/$subdir1/raw  |awk '/^-/ {print $NF}' |awk '/ir/ {print $NF}' | awk '/_'$index'.bmp/ {print $1}')file_speckle=$(ls -l $data_root_dir/$subdir/$subdir1/raw  |awk '/^-/ {print $NF}' |awk '/speckle/ {print $NF}' | awk '/_'$index'.bmp/ {print $1}')file_rgb=$(ls -l $data_root_dir/$subdir/$subdir1/data/rgb  |awk '/^-/ {print $NF}' |awk '/rgb/ {print $NF}' | awk '/_'$index'.jpg/ {print $1}')echo $data_root_dir/$subdir/$subdir1/raw/$file_irecho $data_root_dir/$subdir/$subdir1/raw/$file_speckleecho $data_root_dir/$subdir/$subdir1/data/rgb/$file_rgbmkdir -vp ./data/$subdir/$subdir1/$index/#mkdir -vp ./data/$output_root_dir/$subdir/$subdir1/raw/$index/./bin/RelWithDebInfo/depth_magic_runner.exe \$data_root_dir/$subdir/$subdir1/raw/$file_speckle \--ir $data_root_dir/$subdir/$subdir1/raw/$file_ir \--rgb $data_root_dir/$subdir/$subdir1/data/rgb/$file_rgb \--config $data_root_dir/$config_dir/$config_name \# --set_depth_hdr_mode=true# --rotate_ir_img=truemv -f ./debug_output/* ./data/$subdir/$subdir1/$index/#mv -f ./debug_output/* ./data/$output_root_dir/$subdir/$subdir1/raw/$index/donedone   fi
done   

Bash脚本1.0

#!/bin/bashdir=(
"100cm三角/"
"80cm三角/"
)for((i=0;i<=30 ;i++))doecho "The dir is: ${dir[$i]}"mkdir -vp ./data/${dir[$i]}/depth_image/./bin/depth_magic_runner /home/sun/company/优图测试0616/${dir[$i]}\1SPEACKLEIMAGE.bmp \--ir /home/sun/company/优图测试0616/${dir[$i]}\1IRIMAGE.bmp  \--rgb /home/sun/company/优图测试0616/${dir[$i]}\1RGBIMAGE.jpg \--config /home/sun/company/004/ --deptrum_prefix ./data/${dir[$i]}/depth_image/done# do
#   for((i=1;i<=1 ;i++))
#   do
#     for((index=1;index<=1;index++))
#     do
#     echo "The dir is:${dir[$i]}/$index"
#     mkdir -vp ./data/${dir[$i]}/depth_image\[$index\]/
#     ./bin/depth_magic_runner /home/sun/company/优图测试0616/${dir[$i]}\[$index\]SPEACKLEIMAGE.bmp \
#     --ir /home/sun/company/优图测试0616/${dir[$i]}\[$index\]IRIMAGE.bmp  \
#     --rgb /home/sun/company/优图测试0616/${dir[$i]}\[$index\]1RGBIMAGE.jpg \
#     --config /home/sun/company/004/ --deptrum_prefix ./data/${dir[$i]}/depth_image\[$index\]/
#     done
#   done
# donesun@sun:~/company/deptrum/depth-magic$ 
  for((i=1;i<=31 ;i++))doecho "The dir is: ${dir[$i]}"mkdir -vp ./data/${dir[$i]}/depth_image/./bin/depth_magic_runner /home/sun/company/优图测试0616/${dir[$i]}\1SPEACKLEIMAGE.bmp \--ir /home/sun/company/优图测试0616/${dir[$i]}\1IRIMAGE.bmp  \--rgb /home/sun/company/优图测试0616/${dir[$i]}\1RGBIMAGE.jpg \--config /home/sun/company/004/ --deptrum_prefix ./data/${dir[$i]}/depth_image/done
#!/bin/bash# index=1
# while(( $index<=10 ))
# do
#     mkdir -vp ./data1/speckle_raw\[$index\]/
#     echo $index
#     ./depth_magic_runner ~/data/fill_hole/50/LaserOn/IR_RAW/speckle_raw\[$index\].raw --ir ~/data/fill_hole/50/LaserOff/IR_RAW/speckle_raw\[$index\].raw  --rgb ~/data/fill_hole/50/LaserOn/RGB/rgb\[$index\].bmp --config ~/data/fill_hole/001/ --deptrum_prefix ./data1/speckle_raw\[$index\]/
#     let "index++"
# done# int=1
# while(( $int<=5 ))
# do
#     echo $int
#     let "int++"
# donedir=(
"Dis_30_Cur_1.8_Exp_2.1_Gain_1_2020-06-01-14-06-15-680/"
"Dis_30_Cur_1.8_Exp_2.2_Gain_1_2020-06-01-14-06-18-623/"
)dir1=(
"Dis\ \(30\)\ Cur\ \(1.8\)\ Exp\ \(2.1\)\ Gain\ \(1\)_2020-06-01-14-06-15-680/"
"Dis\ \(30\)\ Cur\ \(1.8\)\ Exp\ \(2.2\)\ Gain\ \(1\)_2020-06-01-14-06-18-623/"
)# for distance in 30 50 80 100
for distance in 100
dofor((i=1;i<=1 ;i++))dofor((index=1;index<=10;index++))doecho "The dir is: $distance/${dir[$i]}/$index"mkdir -vp ./data2/$distance/${dir[$i]}/speckle_raw\[$index\]/./depth_magic_runner ~/data/fill_hole/Fatman-mini-001_NBF_人脸#0601/$distance/$i/LaserOn/IR_RAW/speckle_raw\[$index\].raw \--ir ~/data/fill_hole/Fatman-mini-001_NBF_人脸#0601/$distance/$i/LaserOff/IR_RAW/speckle_raw\[$index\].raw  \--rgb ~/data/fill_hole/Fatman-mini-001_NBF_人脸#0601/$distance/$i/LaserOn/RGB/rgb\[$index\].bmp \--config ~/data/fill_hole/Fatman-mini-001_NBF_1.8A#0512/ --deptrum_prefix ./data2/$distance/${dir[$i]}/speckle_raw\[$index\]/donedone
done

批量读文件批量命名

#include <gflags/gflags.h>int aa = 0;
DEFINE_string(deptrum_edge, "./debug_output/", "Prefix to be added to the debug output filename");std::string edge_image_name = FLAGS_deptrum_edge + std::to_string(aa++)+"rgb_roi_on_color.bmp";
cv::imwrite(edge_image_name, trace_edge_color);

之前帮师弟写个一个批量读取图片并且批量修改图片名的功能的小程序,mark一下便于以后复用。

#include <iostream>
#include <sstream>
#include <string>
#include <io.h>
#include <string.h>
using namespace std;
const int N = 4;
const string fileType = ".jpg";
string int2string(int n, int i);
/*created by sunshine on 2018/5/2*/
int main()
{_finddata_t file;  string fileDirectory = "C:\\Users\\Administrator\\Desktop\\owner\\一餐厅"; //文件夹目录,自己修改  string buffer = fileDirectory + "\\*" + fileType;intptr_t hFile;hFile = _findfirst(buffer.c_str(), &file); if (hFile == -1L)cout << "没有指定格式的图片" << endl;//没有指定格式的图片  else{/**   序号控制  你只需要改正i就OK了,然后配合上面的string fileDirectory指向你的绝对路径  ,后期要是大批量处理的话  可以在进一步扩展一下这个程序*/int i = 530;string newFullFilePath;string oldFullFilePath;string strName;do{oldFullFilePath.clear();newFullFilePath.clear();strName.clear();oldFullFilePath = fileDirectory + "\\" + file.name;++i;strName = int2string(N, i); //类型转换  //char p[20] = "mi-note3-0102-"//第二个字符串  //strName =strcpy(strName, p);//将第一个字符串p拷贝到q中 newFullFilePath = fileDirectory + "\\" +"mi-note3-0102-"+ strName + fileType;int c = rename(oldFullFilePath.c_str(), newFullFilePath.c_str());//重命名  if (c == 0)cout << "重命名成功" << strName << fileType << endl;elsecout << "重命名失败" << strName << fileType << endl;} while (_findnext(hFile, &file) == 0);_findclose(hFile);}system("pause");return 0;
}string int2string(int n, int i)
{char s[BUFSIZ];sprintf_s(s, "%d", i);int len = strlen(s);if (len > n){cout << "输入的N太小!";}else{stringstream Num;for (int i = 0; i < n - len; i++)Num << "0";Num << i;return Num.str();}
}
  std::string filename1 = "./debug_output/points1.txt";FILE* fp = fopen(filename1.c_str(), "at+");cv::Mat norm_obj_points, norm_ref_points;for (std::vector<cv::Point2d>::iterator points1it = points1.begin(); points1it != points1.end(); points1it++) {//std::cout << (*vit).x<<"     " << (*vit).y << std::endl;fprintf(fp,"%10.4f%10.4f\n",(*points1it).x,(*points1it).y);}fclose(fp);std::string filename2 = "./debug_output/points2.txt";FILE* fp2 = fopen(filename2.c_str(), "at+");for (std::vector<cv::Point2d>::iterator points2it = points2.begin(); points2it != points2.end(); points2it++) {//std::cout << (*vit).x<<"     " << (*vit).y << std::endl;fprintf(fp2,"%10.4f%10.4f\n",(*points2it).x,(*points2it).y);}fclose(fp2);

std::string filename = "./debug_output/theta.txt";
    FILE* fp = fopen(filename.c_str(), "at+");        
                    fprintf(fp,
                            "%10.4f %10.3f %10.3f %10.3f %10.2f\n",
                            self_calib_theta_,
                            self_calib_theta_x,
                            self_calib_theta_y,
                            self_calib_theta_z,
                            mean_move_y);

fclose(fp);

bash脚本【一】——批量处理文件相关推荐

  1. Linux下shel脚本之批量修改文件扩展名

    Linux下shel脚本之批量修改文件扩展名 一.脚本要求 二.脚本内容 三.运行脚本 一.脚本要求 二.脚本内容 三.运行脚本 一.脚本要求 1.在/data/tmp/下的所有文件扩展名改为.py ...

  2. php批量替换文件内容,Shell脚本实现批量替换文件内容

    Shell脚本实现批量替换文件内容 今天同事发现内部服务器的硬盘空间不够了,上面有很多备份,我又不能删除,重新找了个320g的硬盘挂载了上,想以后shell脚本下的备份都转移到新硬盘上,给老硬盘腾出空 ...

  3. 如何在Bash脚本中将Heredoc写入文件?

    如何在Bash脚本中将Here文档写入文件? #1楼 代替使用cat和I / O重定向,可以使用tee代替: tee newfile <<EOF line 1 line 2 line 3 ...

  4. 脚本篇-批量添加文件前缀,省时省力

    批量添加文件前缀,省时省力 1.安装python3环境 2.将需要修改的文件和脚本统一放在一个文件夹下,执行命令,输入需要添加的前缀就行. 代码如下: 1.安装python3环境 python3安装包 ...

  5. linux 递归修改文件名,Bash脚本递归查询批量修改文件名

    前言 需求是批量修改.crt和.key为ssl.chain.crt和server.key,为什么会有这样的需求主要是踩了一个大坑Sectigo AddTrust External CA Root Ex ...

  6. (小脚本) (python) 批量修改文件后缀名

    文章目录 前言 完整代码 效果展示 原目录结构 运行展示 修改效果 代码讲解 主要函数 os.walk(path) 判断文件 修改 END 前言 有时候我们需要批量修改一些文件的后缀名 作为程序员我们 ...

  7. linux批量重命名脚本,Linux批量命名文件SH脚本整理

    将所有txt重命名为L_1.txt#!/bin/bash i=0 for name in *.txt do echo "$name" let i=i+1 echo "$i ...

  8. Windows批处理脚本实现批量复制文件并重命名

    有的时候,我们需要对存储位置具有一定规律的大量相似文件进行复制移动和重命名.例如,我最近使用labelme工具标注了一批图片数据,但是每个图片自己生成了一个文件夹.然而在使用的时候,要求所有的图片放在 ...

  9. 【脚本】7-Zip 批量压缩文件

    @echo off ::请用notepad+++编辑脚本,并将编码方式保存为ANSI格式 ::此脚本在批量压缩文件过程中,会因为文件名中有空格报错,所以一定要使得被压缩文件名字中无空格 echo 7z ...

  10. shell 批量转换文件编码

    相信大家在平时的跨平台编程中碰到过文件编码问题,比如在Windows代码字符编码方式是GB2312,然而转到Linux却只支持utf-8,虽然对代码部分没啥影响,但是很多中文注释部分,却一片乱码,很让 ...

最新文章

  1. 华为atn980传输设备_注册开发者超200万!华为HMS加速全球布局,打造全场景智慧体验...
  2. 17_传智播客iOS视频教程_代码中的面向过程与面向对象以及优缺点分析
  3. hdu 2879【留坑】
  4. Mac 配置支持 opengl 的 opencv 4.2
  5. maven 公共模块依赖_「spring-boot 源码解析」spring-boot 依赖管理
  6. Python:使用threading模块实现多线程编程三[threading.Thread类的重要函数]
  7. 小白程序员仅用 5 分钟入职 BAT,他只做了这件事!
  8. CCCC-GPLT L3-013. 非常弹的球 团体程序设计天梯赛
  9. python自动化办公要学多久-基于python实现自动化办公学习笔记三
  10. Storm入门之第8章事务性拓扑
  11. 【安卓开发】Android平台的记账本app(全部代码+room框架操作数据库+设计报告)
  12. REFPROP+matlab拟合物性参数公式
  13. CCF推荐期刊会议(A类)
  14. linux 联机游戏下载,星露谷物语多人联机版
  15. error C279: ‘parament‘: multiple initialization
  16. 【无线网络技术专题(十一)】无线网络常用软件与工具大全
  17. linux申请令牌错误,解决“请求中包含的安全令牌已过期”错误
  18. idea发送请求提示 无法保留cookie.cookie storage file is included in ignored list:
  19. QoS服务质量二令牌桶算法及QoS业务分类
  20. 图片内容巴特勒 (隐藏文字到图片)

热门文章

  1. 大根堆的删除c语言,二叉堆(一)之 C语言详解
  2. C/C++ 读取任意数目的整数
  3. 计算机协会成立活动简报,“中国计算机学会CCF走进高校”活动在我校举行
  4. catia今天突然打不开了_苹果手机锁屏密码突然不正确了?不要慌!也先不要着急刷机!!!尝试一下以下方式!...
  5. PCL基础2:点云赋值
  6. 小R SLAM机器人树莓派3b+ ROS kinetic 环境搭建笔记
  7. BorderDet(论文解读)
  8. 【yolo目标检测】(1) yolov3,网络结构Darknet53,特征提取
  9. linux arm中断跑马灯,S3C2410 MDK实验---ARM汇编语言实现跑马灯
  10. 张正友相机标定代码(c++python)