Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Jacob_kreed

macrumors newbie
Original poster
Mar 11, 2023
3
0
I am copying data from a Mac Mini to Windows Server, and I am using CP code in terminal

I am on MacOSX 10.10 and 10.8, what is the syntax to copy either modified files only or files of a specific date. I rsync exists but I need to CP command, if any one can advise, pretty please
 

pws442

macrumors newbie
Feb 23, 2011
23
6
I asked my BUD this question: "Can you specify dates with CP?"

Here's what I got:

Yes, you can use the --newer and --newer-mtime options in cp to copy only files that are newer than a specified date or file.

Here are some examples:

# Copy all files from source directory modified on or after March 1, 2023
cp -Rup --newer="2022-03-01" "source/" "destination/"

# Copy all files from source directory modified after the modification time of file.txt
cp -Rup --newer-mtime="file.txt" "source/" "destination/"


In the first example, --newer="2022-03-01" specifies that only files modified on or after March 1, 2022, should be copied.

In the second example, --newer-mtime="file.txt" specifies that only files modified after the modification time of file.txt should be copied.

Note that --newer uses the file modification time, while --newer-mtime uses the system's current time as the reference point for comparison.

I hope this helps!
 
  • Like
Reactions: Jacob_kreed

Jacob_kreed

macrumors newbie
Original poster
Mar 11, 2023
3
0
I asked my BUD this question: "Can you specify dates with CP?"

Here's what I got:

Yes, you can use the --newer and --newer-mtime options in cp to copy only files that are newer than a specified date or file.

Here are some examples:

# Copy all files from source directory modified on or after March 1, 2023
cp -Rup --newer="2022-03-01" "source/" "destination/"

# Copy all files from source directory modified after the modification time of file.txt
cp -Rup --newer-mtime="file.txt" "source/" "destination/"


In the first example, --newer="2022-03-01" specifies that only files modified on or after March 1, 2022, should be copied.

In the second example, --newer-mtime="file.txt" specifies that only files modified after the modification time of file.txt should be copied.

Note that --newer uses the file modification time, while --newer-mtime uses the system's current time as the reference point for comparison.

I hope this help
 

Jacob_kreed

macrumors newbie
Original poster
Mar 11, 2023
3
0
I asked my BUD this question: "Can you specify dates with CP?"

Here's what I got:

Yes, you can use the --newer and --newer-mtime options in cp to copy only files that are newer than a specified date or file.

Here are some examples:

# Copy all files from source directory modified on or after March 1, 2023
cp -Rup --newer="2022-03-01" "source/" "destination/"

# Copy all files from source directory modified after the modification time of file.txt
cp -Rup --newer-mtime="file.txt" "source/" "destination/"


In the first example, --newer="2022-03-01" specifies that only files modified on or after March 1, 2022, should be copied.

In the second example, --newer-mtime="file.txt" specifies that only files modified after the modification time of file.txt should be copied.

Note that --newer uses the file modification time, while --newer-mtime uses the system's current time as the reference point for comparison.

I hope this helps!
Good afternoon Pws442, I am trying to copy 9 march 2023 and there after , but when I have used -Rup command its says that -u command is illegal....
 

Greybeard2017

macrumors member
Dec 7, 2020
75
108
Maybe the BUD was a Linux user - if you are still looking for an answer then the find command will do it

find . -mtime -11 -depth 1 -exec cp {} tmp2 \;

this will copy everything changed in the last 11 days from the current directory to the tmp2 sub-directory
(and ignore anything in sub-directories)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.