How to recover “deleted” files in Linux on an NTFS filesystem (files originally from macOS)
10
votes
8
answers
9977
views
My girlfriend has a external hard disk with 10 years+ of photos, documents and more. A lot of these files originate from her old iPhone 5 and her MacBook. The hard disk itself is NTFS Format. Since the disk is so old, it turns into a hazard of data loss (what an irony).
As we tried to upload all the files into OneDrive to store them safely, we got 1,000s of errors because of invalid file names. I realized that many files started with
._
, e.g. ./pic/92 win new/iphone/._IMG_1604.JPG
. I don't understand macOS and why files should be named like that, but for sure you can never get them into OneDrive like that.
So I decided to hook it to my Raspberry Pi and rename all files with the wrong characters from the command line. After listing the nearly 10,000 files, I ran the following over the whole hard disk.
find . -name "._*" | sed -e "p;s/\._//" | xargs -d '\n' -n2 mv
Furthermore, I removed some leading whitespace in filenames with zmv.
I tried the command in a test environment first and it looked fine. But I didn't check the file size.
After my girlfriend connected the hard disk back onto her Mac, all renamed files show a file size of 4KB (empty)! **I screwed it up** and I don't know how.
I assume the data is still there, but I somehow screwed the filesystem.
Does anybody understand what I did wrong? More importantly, do you see a chance to recover the files? I would appreciate any advice.
Asked by LukasH
(109 rep)
Mar 6, 2021, 05:15 PM
Last activity: Apr 26, 2025, 09:30 PM
Last activity: Apr 26, 2025, 09:30 PM