0

I'm on macOS Mojave 10.14.4, on a APFS SSD. Last week some students delivered me some image files over an image processing assignment. I have an automated routine on Matlab to grade the assignments, but it only loads files with a specific ".jpeg" extension.

Rather than rewrite my routine, I usually just rename the files (a mess of ".jpg", ".JPEG", ".JPG") on terminal. I'm used to do that on my University issued linux desktop. But that day I had my MacBook Pro with me, so I got them with it.

Alas, my terminal command "mv *.jpg *.jpeg" returned with a no such file or directory error, so I left this task for later. Earlier today I got to work after a three day weekend and when I opened the folder, I realized that about half of the files were missing.

My guess is that the mv didn't "fail properly" and, based on some thing that I've already looked around, may have lost the data for good! My Time Machine is at home, so it never got to back up those files.

I have already looked for possibly hidden folders where the files might have ended up, but no luck. Does anyone has any idea where the files may have gone? Or if they are truly lost?

Att.

Osmar

  • mv *.jpg *.jpeg does not rename all files ending in .jpg to .jpeg (DOS and Windows do have the rename command that does that) mv will move all its inputs except the last one to the last one. See Unix Haters handbook page 189. Yes you have lost data. – user151019 Apr 22 at 17:32
  • Ok, not too much trouble. It does work that way on Ubuntu though, and I just assumed it would be the same on my Mac. Thanks for the answer and the reference. – Osmar Tormena Junior Apr 22 at 17:37
  • 2
    mv does not work that way on any Unix. The *.jpg and *.jpeg are expanded to actual file names before being passed to mv SO if you have a.jpg and b.jpg the shell expands the command mv *.jpg *.jpeg to mv a.jpg b.jpg – user151019 Apr 22 at 17:42
  • Are you sure the files are missing? mv *.jpg *.jpeg will throw an error if there are more then two names after wildcard expansion (and the second name can even be a literal *.jpeg). So to loose files you would need to have exactly one file matching the *.jpg part and one (or none) matching the *.jpeg pattern, and then run the command again after the next whatever.jpg got moved into the directory. – nohillside Apr 22 at 17:57
  • Can you . run the command find . -name "*.jpeg" and report the output to us? This should find the files if they're somewhere in the proximity to where you ran this command. – slm Apr 22 at 18:12
1

If you have a directory/folder of JPEG files that have either a .jpg and or .JPG extension and you want to change the extension to .jpeg, then in Terminal, use the following compound command after changing directory cd ... to the directory containing the JPEG files:

for f in *.[jJ][pP][gG]; do mv -n "$f" "${f%.*}.jpeg"; done
-1

Try completing your Time Machine backup. macOS uses the free space on your hard disk to do backups of changed/new files hourly and writes those to your backup disk when you connect to your Time Machine.

It's quite likely that if you do a Time Machine backup, then search for your missing files, you'll find them.

Good luck!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .