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.
mv -i
which would stop rather than clobber existing files.._
files (which are irrelevant anyway, see my answer), were the rest uploaded? If so, everything is absolutely fine, all files have been backed up and only the._
files were ignored which is not a problem at all.._*
files holding the metadatadd
or some similar tool since there might be some exceptional situations whereby mounting itself can write data, but I'm not sure how this goes with NTFS.