Skip to content

Instantly share code, notes, and snippets.

@kjlape
Last active July 12, 2016 14:29
Show Gist options
  • Select an option

  • Save kjlape/df72ff338c200de6dc40fed8ec918475 to your computer and use it in GitHub Desktop.

Select an option

Save kjlape/df72ff338c200de6dc40fed8ec918475 to your computer and use it in GitHub Desktop.
Useful directory merging commands.
# METHOD 1:
# use this when there's a reasonable number of subdirectories
mv dir1/* dir2/* dir3/* ... DESTINATION
# Then if there are conflicts...
cp -Rn dir2/* DESTINATION
cp -Rn dir3/* DESTINATION
#METHOD 2:
# use this when there are too many subdirectories for mv to handle as args at once
for dir in ./*; do mv "$dir" DESTINATION; done
# --remove-source-files is technically optional, and could slow down the process; omit if disk space is not a constraint
for dir in ./*; do rsync -avhP --remove-source-files "$dir" DESTINATION; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment