Last active
April 24, 2020 14:42
-
-
Save mfehr/5a2ca084cd22af4cfb3549283c300343 to your computer and use it in GitHub Desktop.
Move all files in tree to root folder, delete all subfolders and auto-remove all duplicate files.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
find $1 -type f -exec mv --backup=numbered -t $1 {} + | |
find $1 -type d -empty -delete | |
fdupes -rdNS $1 | |
# Sources: | |
# - https://superuser.com/questions/658075/how-do-i-move-files-out-of-nested-subdirectories-into-another-folder-in-ubuntu | |
# - https://unix.stackexchange.com/questions/8430/how-to-remove-all-empty-directories-in-a-subtree |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment