In spite of dramatic improvements in filesystem technologies, corruption is still an issue that continues to this day in computing whether it be on the desktop and/or on more portable devices. Recently my Android based phone endured something along these lines. A number of folders had become files and there were randomly named files spread throughout the filesystem on the SD card with unreadable characters. Research indicated that this was a problem that has been experienced before by others (though the type of corruption often varies).
Luckily in my case, all important data was still retained but it was still disconcerting to say the least. The way I dealt with it was by connecting my phone via USB to my laptop and set the connection to run in mass storage mode. Thereafter, I ran 'Scandisk' (FAT32 filesystem is used on the SD card) in order to determine the causes and hopefully create the fixes required in order to achieve filesystem consistency. Obviously, it would store the files in various CHK files. Still had permission errors though. Upon further examination certain directories seemed to have have become files which resulted not being able to save files from camera shots for photos (DCIM) or wallpapers (Wallpaper). By manually recreating the relevant directories and copying back the relevant files to the relevant data directories you could restore most data. By using the built-in image viewer you could regenerate relevant metadata. Obviously, I'm still looking for a more elegant solution that can be built into the device itself.