'Movefile' made a new directory but it can't be opened

2 views (last 30 days)
Situation: I was using movefile() to move data files to another directory. The data files were .mat format. The destination directory did not exist so MATLAB automatically created the destination folder (let's call this new directory problem_directory).
Problem: The folder problem_directory that was created is not recognized as a folder by Windows - the file type is 'File' in Windows Explorer and I can't open it to get to the data file inside.
What I tried so far: I tried to 'Open with' Notepad and MATLAB, but neither worked. In both cases, the file presented on the first line
MATLAB 5.0 MAT-file, Platform: PCWIN64, Created on: Fri Dec 19 09:41:35 2014
followed by screeds of garbage characters (I imagine due to incorrect decoding).
When I use
folders = dir('source\')
where source is the source folder of problem_directory, the field isdir for problem_directory has value 0 (I suppose this confirms that MATLAB does not recognize it as a folder).
Request: How can I force this directory to be recognized as a folder, so that I can open it and access the file inside which I copied over?
Thank you!

Answers (1)

Walter Roberson
Walter Roberson on 17 Jul 2015
Whatever method you used to create the output name has ended up using the folder name as being the file name. You movefile()'d a bunch of different files into the same file name. The result is whichever .mat file you movefile()'d last, but possibly without its .mat extension. The other files are gone and cannot be recovered except perhaps by some kind of undelete utility. Time to recover them from your backup.

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!