Created
December 16, 2021 19:31
-
-
Save emjayoh/d9dfa3f3c4cb43f6bf6a2218bdf39b44 to your computer and use it in GitHub Desktop.
[move sub^2 dir to parent dir] #bash
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
#!/bin/bash | |
#needed in case we have empty folders | |
shopt -s nullglob | |
#we must write the full path here (no ~ character) | |
target="/path/to/photos" | |
#we use a glob to list the folders. parsing the output of ls is baaaaaaaddd !!!! | |
#for every folder in our photo folder ... | |
for dir in "$target"/*/ do | |
#we list the subdirectories ... | |
for sub in "$dir"/*/ do | |
#and we move the content of the subdirectories to the parent | |
mv "$sub"/* "$dir" | |
#if you want to remove subdirectories once the copy is done, uncoment the next line | |
#rm -r "$sub" | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment