Where could possibly disappear my files after using movefile()?
Show older comments
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
Stephen23
on 11 Dec 2017
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.
Adam
on 11 Dec 2017
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.
Maria Tikhomirova
on 12 Dec 2017
Nirajan Luintel
on 30 Mar 2018
Did you find the location of missing files? I tried using windows search but could not find anywhere.
Image Analyst
on 31 Mar 2018
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.
Answers (1)
Image Analyst
on 11 Dec 2017
0 votes
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
Maria Tikhomirova
on 11 Dec 2017
Image Analyst
on 11 Dec 2017
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.
Maria Tikhomirova
on 11 Dec 2017
Image Analyst
on 11 Dec 2017
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?
Maria Tikhomirova
on 12 Dec 2017
Image Analyst
on 12 Dec 2017
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.
Categories
Find more on Whos 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!