how to change file names in matlab
2017-01-04 01:22
411 查看
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 photo name = extractfield(pics, 'name');% extract name fields into a cell array index = ~ismember(name,[ {'.'},{'..'}]);%exclude current directory and parent directory name = name(index); gif = regexp(name, '.gif$');%find out the original gif files index_nongif = cellfun(@isempty, gif);% filter out gif files name = name(index_nongif); before_name = cellfun(@strcat, repmat({'photo\'},size(name)), name, 'UniformOutput', 0);% add photo prefix after_name = cellfun(@strcat, before_name, repmat({'.gif'},size(name)), 'UniformOutput', 0);% add .gif suffix cellfun(@movefile, before_name, after_name)% change file names
相关文章推荐
- How to Change the Size of a Box-Plot Label in MATLAB
- How to change the name in open with list / File association.
- 【转】How to Change File Ownership & Groups in Linux
- git tip: How to undo an uncommitted change/deletion for a specific file in your working directory
- Howto change all file and directory in a folder to 777?
- How to Change the Icon for a File Type in Windows 7 and Vista(转)
- how to upload a file to server/ how to modify a file in server
- Understanding Object Ownership in sql 2000(how to change the schema table name in sql 2000)
- How to migrate plug-in mmp file to satisfy new security request
- How to re-create STM File in Exchange 2000/2003
- How to Determine if a file is a .Net assembly (in Delphi and C#)
- How to Change The Bootsplash In Ubuntu 8.10
- How to Modify the web.config file in SharePoint using SPWebConfigModification?
- How to change service accounts and service account passwords in SharePoint Server 2007 and in Windows SharePoint Services 3.0
- How to Open a Text File in VB .NET
- [Tips] How to Add New field into Shapefile attribute table in ArcGIS ?
- how to change folder's sort number in sharepoint?
- How to remove ^M in a uploaded text file?
- XDB:How to change XDB in XE to enable remote listener.
- How to read Mac .DMG file in Linux or PC(II)