Reputation: 4282
I would like to copy the structure of an existing folder including folders and files but I would like the size of the files to be 0. So it would create an empty file, with the same name and extension.
I know how to do it by running : robocopy source destination /create /e /xc /xn /xo
What is the equivalent command I could use on Mac ?
Upvotes: 1
Views: 1729
Reputation: 7801
Here is a script that might do what you want.
#!/usr/bin/env bash
source=$1
dest=$2
while IFS= read -rd '' file; do
mkdir -p "$dest${file%/*}" || exit
touch -r "$file" "$dest$file"
done < <(find "$source" -type f -print0)
Howto use
./myscript source/ destination/
Upvotes: 1