Files disappearing when trying to use movefile

3 views (last 30 days)
I am sure this is just a simple syntax error, but I am trying to move files from the current folder to a subfolder called 'Used' within the current folder.
I thought that the following line would work:
movefile('filename.mat', '../Used');
While this does not produce an error message, it permanently deletes the file in question.
I've tried different ways of referencing the 'Used' folder, but they all give me an error message about the file/directory not existing.
What am I doing wrong?

Answers (1)

Azzi Abdelmalek
Azzi Abdelmalek on 5 Jul 2016
Edited: Azzi Abdelmalek on 5 Jul 2016
If you want to move filename.mat from folder1 to folder2
folder1='C:\Users\malek\Documents\path1'
folder2='C:\Users\malek\Documents\path2'
movefile(fullfile(folder1,'filename.mat'),fullfile(folder2,'filename.mat'))

Categories

Find more on File Operations in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!