命令行保存指定目录文件的名字(可包含文件夹文字)到txt文本文件
程序员文章站
2022-04-17 14:04:18
...
Microsoft Visual Studio中配置OpenCV解决方案属性的时候, 需要将OpenCV的lib扩展名的库文件添加到属性的依赖列表里面,网上的有些人博客里面直接给出的会有问题(但大多数是好的),自己动手丰衣足食,开始:
1、要读取文件名字的文件夹位置如下,我们要记住: D:\opencv\build\install\x64\vc12\lib
2、然后打开系统的命令行(不需要管理员权限):
命令行显示当前处于C:\Users\HooS目录下。
然后在命令行界面输入:
dir D:\opencv\build\install\x64\vc12\lib\*.lib /b > note1.txt
其实格式就是" dir 格式1 /b > 格式2 "。
格式1: 指明去哪里找什么样的文件名字。 假如格式一是" *.lib "的话就是在当前路径下找所有lib扩展名的文件; 假如格式一是" * "的话就是找当前路径下所有文件和文件夹的名字; 扩展一下," D:\opencv\build\install\x64\vc12\lib\*.lib "只是换了个绝对路径而已, 找的是那个文件夹下面的所有lib扩展名的文件的名字。格式2:指明保存到哪里 " note1.txt "表明将那些名字保存到当前目录下的note1.txt文本文件里, 而相应的我们可以指定保存到某个指定位置:" d:\note1.txt "就是保存到D盘根目录下的note1.txt文件里面。
然后就生成了文本文件:(生成位置在C:\Users\HooS(HooS是我的用户名)下面)
生成的文件内容如下:
opencv_calib3d2413.lib
opencv_calib3d2413d.lib
opencv_contrib2413.lib
opencv_contrib2413d.lib
opencv_core2413.lib
opencv_core2413d.lib
opencv_features2d2413.lib
opencv_features2d2413d.lib
opencv_flann2413.lib
opencv_flann2413d.lib
opencv_gpu2413.lib
opencv_gpu2413d.lib
opencv_highgui2413.lib
opencv_highgui2413d.lib
opencv_imgproc2413.lib
opencv_imgproc2413d.lib
opencv_legacy2413.lib
opencv_legacy2413d.lib
opencv_ml2413.lib
opencv_ml2413d.lib
opencv_nonfree2413.lib
opencv_nonfree2413d.lib
opencv_objdetect2413.lib
opencv_objdetect2413d.lib
opencv_ocl2413.lib
opencv_ocl2413d.lib
opencv_photo2413.lib
opencv_photo2413d.lib
opencv_stitching2413.lib
opencv_stitching2413d.lib
opencv_superres2413.lib
opencv_superres2413d.lib
opencv_ts2413.lib
opencv_ts2413d.lib
opencv_video2413.lib
opencv_video2413d.lib
opencv_videostab2413.lib
opencv_videostab2413d.lib
假如想要保存的名字是绝对路径,那么修改下即可:
dir D:\opencv\build\install\x64\vc12\lib\*.lib /b/s > note2.txt
生成的note2.txt内容如下:
D:\opencv\build\install\x64\vc12\lib\opencv_calib3d2413.lib
D:\opencv\build\install\x64\vc12\lib\opencv_calib3d2413d.lib
D:\opencv\build\install\x64\vc12\lib\opencv_contrib2413.lib
D:\opencv\build\install\x64\vc12\lib\opencv_contrib2413d.lib
D:\opencv\build\install\x64\vc12\lib\opencv_core2413.lib
D:\opencv\build\install\x64\vc12\lib\opencv_core2413d.lib
D:\opencv\build\install\x64\vc12\lib\opencv_features2d2413.lib
D:\opencv\build\install\x64\vc12\lib\opencv_features2d2413d.lib
D:\opencv\build\install\x64\vc12\lib\opencv_flann2413.lib
D:\opencv\build\install\x64\vc12\lib\opencv_flann2413d.lib
D:\opencv\build\install\x64\vc12\lib\opencv_gpu2413.lib
D:\opencv\build\install\x64\vc12\lib\opencv_gpu2413d.lib
D:\opencv\build\install\x64\vc12\lib\opencv_highgui2413.lib
D:\opencv\build\install\x64\vc12\lib\opencv_highgui2413d.lib
D:\opencv\build\install\x64\vc12\lib\opencv_imgproc2413.lib
D:\opencv\build\install\x64\vc12\lib\opencv_imgproc2413d.lib
D:\opencv\build\install\x64\vc12\lib\opencv_legacy2413.lib
D:\opencv\build\install\x64\vc12\lib\opencv_legacy2413d.lib
D:\opencv\build\install\x64\vc12\lib\opencv_ml2413.lib
D:\opencv\build\install\x64\vc12\lib\opencv_ml2413d.lib
D:\opencv\build\install\x64\vc12\lib\opencv_nonfree2413.lib
D:\opencv\build\install\x64\vc12\lib\opencv_nonfree2413d.lib
D:\opencv\build\install\x64\vc12\lib\opencv_objdetect2413.lib
D:\opencv\build\install\x64\vc12\lib\opencv_objdetect2413d.lib
D:\opencv\build\install\x64\vc12\lib\opencv_ocl2413.lib
D:\opencv\build\install\x64\vc12\lib\opencv_ocl2413d.lib
D:\opencv\build\install\x64\vc12\lib\opencv_photo2413.lib
D:\opencv\build\install\x64\vc12\lib\opencv_photo2413d.lib
D:\opencv\build\install\x64\vc12\lib\opencv_stitching2413.lib
D:\opencv\build\install\x64\vc12\lib\opencv_stitching2413d.lib
D:\opencv\build\install\x64\vc12\lib\opencv_superres2413.lib
D:\opencv\build\install\x64\vc12\lib\opencv_superres2413d.lib
D:\opencv\build\install\x64\vc12\lib\opencv_ts2413.lib
D:\opencv\build\install\x64\vc12\lib\opencv_ts2413d.lib
D:\opencv\build\install\x64\vc12\lib\opencv_video2413.lib
D:\opencv\build\install\x64\vc12\lib\opencv_video2413d.lib
D:\opencv\build\install\x64\vc12\lib\opencv_videostab2413.lib
D:\opencv\build\install\x64\vc12\lib\opencv_videostab2413d.lib