I have a lot of folders named Archive.folder in /var/CommuniGate/Accounts/*/. How can I move them to a new location and leave a symlink at the old folder to the new location?
Maybe use find and cp to move them?
find /var/CommuniGate/Accounts/ -name 'Archive.folder' -exec cp -r --parents {} . \;
This works fine for moving them and keeping the folder structure. But how can leave a link at the same time with ln? Also the link should replace the old folder.
I've tried executing the following after, it works if there is only one folder.
find /var/CommuniGate/Accounts/ -name 'Archive.folder' -delete
find * -name 'Archive.folder' | xargs -0 -iDIR sh -c 'mkdir -p /$(dirname DIR); ln -s -t /$(dirname DIR) $PWD/DIR'
I get permission denied for the sh -c for everything after the first directory.
You can juste move your file to the desired location and then create the symlink :
mv /var/CommuniGate/Accounts/Archive.folder* new_location/ln -s new_location/Archive.folder* .If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With