The numbers 00001, etc. are account numbers, and I want to copy the files in the directories above to a second server using the structure below (the directories don’t exist).
So for server A, the account number 00001 is identified by the second to last folder (before INBOX) and I want to create a folder on the second server that has the account number after the orders directory.
How would I do that using rsync? Thanks in advance!
I don’t think you can do that with rsync, but you can use whatever scripting language is on that system to manipulate the files before or after you copy them. For example, rsync -Phav default/ orders/. That will recursively copy everything from default to orders, and you’ll have 00001, 00002, etc. Then use the scripting language to go through all of those, move everything in INBOX up one level, and delete the INBOX folder.
Assuming all of your account numbers are uniformly 5 digits, you can get them all in one rsync command using something like this on the destination host:
It would be nice if rsync offered better regular expression support, so you could say to include ‘[0-9]+/’ to match any all-digit directory instead of repeating [0-9] exactly five times, but instead it seems to offer some sort of weird and limiting combination of regexp and globbing.
Too late to edit: Please ignore my last post. I just realized that I misread the OP, and that the INBOXes are directories whose contents are to be copied, and not the files themselves. My mistake, sorry; my response isn’t applicable.