Where could possibly disappear my files after using movefile()?

I wanted to move my files to a directory called 'empty', which is inside of current directory with files. I used
movefile(strcat(list(n,1:22),'A02Z01C02.png'),'\empty')
And my files disappeared! I understand now, that should have used movefile(strcat(list(n,1:22),'A02Z01C02.png'),'empty'), instead, but where can I find my files now?

5 Comments

Search for recently changed files and folders, at the time when those files were moved. Some locations that will be worth taking a closer look at:
  • the current directory
  • your user directory
  • the root drive
I once succeeded in renaming some files in such a way that Windows thought they were folders... it took me a while to identify them, but once I had I simply renamed them back to something useable.
For future reference, get used to providing an explicit full path when moving files or, indeed, doing anything that uses files. Taking shortcuts when something is on the path can be nice, but can also lead to results you weren't expecting all too often, especially for writing files.
For reading files it isn't so bad and I often take the lazy approach when I know a file is on my path and don't give a full path to the file. Still, it never does harm, apart from a bit more typing, to always use an explicit path.
Yeah, now I know..only full path! cannot find them anywhere..
Did you find the location of missing files? I tried using windows search but could not find anywhere.
Nirajan, start your own question and show your code. We don't know what you did and since we can't see your copyfile or movefile line of code, we don't know what your destination for the files is.

Sign in to comment.

Answers (1)

Use the file finding capability of your operating system to find out where it got put. It looks like it should be in a folder called "empty" either off the root of the drive, or as a subfolder of what MATLAB considers the "current folder". But anyway, telling your OS to find A02Z01C02.png should find it.

6 Comments

Thank you for the suggestion, but I couldn't find them like this.
Then it somehow got deleted. Did you have this line in your startup.m or m-file:
recycle on
You might try looking in your recycle bin. Then try the code again with a file that you can afford to lose, like some junk/test file, to verify that the code actually does delete it. If recycle is on, then the file should show up in the recycle bin instead of permanently vanishing.
Checked the recycle bin immediately, but they are not there. 'recycle on' was not there
Yes I figured the original file would not be there because I suspected that you had not set recycle on. But you forgot to tell us what happened when you tried to reproduce it with a test file. Did that file show up in the recycle bin?
Although, I don't see how would it help me to find my files. The test file also disappeared. The recycle was on this time
So you used the full path, starting with the drive letter, had recycle on, and still did not find the destination file? So when you do
status = movefile(sourceFileName, destinationFileName)
what is status?
If status shows it worked, then I'd call tech support.

Sign in to comment.

Tags

Asked:

on 11 Dec 2017

Commented:

on 31 Mar 2018

Community Treasure Hunt

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

Start Hunting!