博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
how to change file names in matlab
阅读量:4041 次
发布时间:2019-05-24

本文共 867 字,大约阅读时间需要 2 分钟。

Assuming we have some files in a fold named 'photo', some file names are ended with '.gif', some of them are not. now our goal is to add '.gif' suffix to all the files except the '.gif' files they were before.

 

pics = dir('photo');%list all the files in folder photoname = extractfield(pics, 'name');% extract name fields into a cell arrayindex = ~ismember(name,[ {'.'},{'..'}]);%exclude current directory and parent directoryname = name(index);gif = regexp(name, '.gif$');%find out the original gif filesindex_nongif = cellfun(@isempty, gif);% filter out gif filesname = name(index_nongif);before_name = cellfun(@strcat, repmat({'photo\'},size(name)), name, 'UniformOutput', 0);% add photo prefixafter_name = cellfun(@strcat, before_name, repmat({'.gif'},size(name)), 'UniformOutput', 0);% add .gif suffixcellfun(@movefile, before_name, after_name)% change file names

转载地址:http://jpxdi.baihongyu.com/

你可能感兴趣的文章
判断俩单链表是否相交
查看>>
前中后序遍历二叉树的非递归实现
查看>>
大数相乘,结果在2000位以内
查看>>
二叉树是否对称
查看>>
动态规划-找零钱
查看>>
动态规划-跳台阶
查看>>
动态规划-01背包问题
查看>>
动态规划-优化编辑器问题
查看>>
堆排序(C++实现)
查看>>
图的俩种遍历方式(DFS,BFS)C++代码实现
查看>>
Hibernate设置主键自增,执行HQL语句
查看>>
设置MYSQL最大连接数与WAIT_TIMEOUT
查看>>
java根据ip地址获取详细地域信息
查看>>
解决s:iterator嵌套s:radio的传值问题
查看>>
位运算-不用加减乘除做加法。
查看>>
C++继承的三种方式(公有,私有,保护)
查看>>
待修改:C++多线程编程学习笔记
查看>>
冒泡、选择、插入、归并
查看>>
QTextEdit显示超链接
查看>>
使用socket下载文件(C++)
查看>>