声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1517|回复: 0

[GUI界面] 求助:关于改文件名

[复制链接]
发表于 2013-3-21 00:26 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
% --- Executes on button press in pushbutton9.
function pushbutton9_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton9 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

global gfile;
[filename3, pathname3, filterindex3] =uigetfile({'*.ts2;*.ts3;*.ts4;*.ts5';'*.ts2';'*.ts3';'*.ts4';'*.ts5'}, 'MultiSelect','on');
pathfile3=strcat(pathname3,filename3);
handles.pathfile3=pathfile3;
handles.filterindex3=filterindex3;
guidata(hObject, handles);
if iscell(handles.pathfile3)
[m,n]=size(handles.pathfile3);
for na=1:n
gfile=[gfile;cellstr(handles.pathfile3(1,na))];
end
else
  gfile=[gfile;cellstr(handles.pathfile3)];
end
assignin('base','gf',gfile);

prompt={'想加字符:'};
def={'a'};
dlgTitle='输入 字符';
lineNo=1;
zf=inputdlg(prompt,dlgTitle,lineNo,def);
assignin('base','zfs',zf);

[m1,n1]=size(gfile);
for m2=1:m1
    [mm,nn]=size(gfile{m2});
    newname = [gfile{m2}(1:nn-4),zf{1},gfile{m2}(nn-3:nn)];
    status = system(['rename'  ' ' gfile{m2}  ' ' newname]);
end

设计了一个按钮,现在选中的文件名后加一个a,比如:文件名为w.txt,变为wa.txt
前面都没错,就最后for循环里的改文件名的system有错,但不知道怎么改,请高手帮帮忙吧!!!
回复
分享到:

使用道具 举报

您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-9-21 00:38 , Processed in 0.059492 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表