How can I move files by creation date in Mac Terminal without errors?
#1
I’ve been trying to get my head around using the command line to automate some file organization on my Mac, but I’m hitting a wall with the syntax for moving files based on their creation date. I followed a guide that mentioned using `find` with `-newer` and `xargs`, but my test just keeps throwing a "No such file or directory" error even though the paths look correct to me.
Reply
#2
That error usually means the reference file or the path you pass isn’t being found by the shell you’re running. On macOS the BSD style of the tool needs a real file to compare against for the date filter, not a directory or missing path. I had to make sure the destination existed first, because if /target doesn’t exist the move step fails with the same message. Also if your file names have spaces or newlines, you’ll blow up unless you use a safe piping method like a null terminated list.
Reply
#3
I tried something similar and kept getting that error until I realized spaces in file names were breaking the pipe. I ended up switching to rsync with a date based filter instead of piping through a mover. It’s clunkier to read, but it didn’t crash on spaces anymore. If you truly want to stick with the original approach, you’ll need the -print0 and -0 pairing and a shell loop, which I’m not sure about.
Reply
#4
Did a tiny workaround: a shell loop that handles each file individually. I used the same approach to grab files newer than a reference, then move them one by one in a loop. It helps with spaces and empty lines. Just make sure the reference file exists and the target directory exists and you have permission.
Reply
#5
One quick question: is the reference file path correct?
Reply


[-]
Quick Reply
Message
Type your reply to this message here.

Image Verification
Please enter the text contained within the image into the text box below it. This process is used to prevent automated spam bots.
Image Verification
(case insensitive)

Forum Jump: