Some files disappeared after using movefile

6 次查看(过去 30 天)
I used movefile to rename thousands of files in a folder (by simply adding a prefix to the original name). To my surprise, almost three quarter of my files disappeared. Has anyone experienced this? Is this a bug? I'm using R2018a.
  3 个评论
John Githaka
John Githaka 2019-10-27
I'm pretty sure it's not the naming scheme. Below is my code (I was renaming tif files. There was no other software open except MATLAB). The files which remained were succesfully renamed.
%Current follder should be the one with images to rename
list=dir('*.tif');%get all tif files
list=extractfield(list,'name'); %get file names
h=waitbar(0,'progress');% progress bar
for i=1:length(list)
waitbar(i/length(list),h)%keep track of progress
OriginalName= list{i}; % define file to rename
NewName= ['Cell2_' OriginalName]; % get new file namename
movefile(OriginalName,NewName)
end
close(h)
John Githaka
John Githaka 2019-10-27
编辑:John Githaka 2019-10-27
I've just figured out what went wrong. You were right, there's nothing wrong with movefile! I was renaming files in a shared remote hardrive that has scheduled file transfers to a backup drive everyday. It just so happened I run my code just when the scheduled transfer was starting!! I've found my missing files in the backup drive.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

产品


版本

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by