Quote:
Originally Posted by elsmandino
Hello.
I would really grateful for some help with a command that help with the following:
I have a single folder called "Movies"(/mnt/Movies).
About half of my movies are in this directory as single files.
However, the other half are in their own directory with the same name as the file e.g. /mnt/Movies/Rocky_(1976)/Rocky_(1976).ts
I want to get rid of these parent folders for the movies.
Is there a command for taking the files out of the parent folders and putting them directly into the Movie folder?
Is there also a command to then remove all the empty parent folders?
|
Yes.
My favorite, magical command known as
find(1)
Along with the wonderful options for it:
-type
-exec
-mindepth (applies)
-maxdepth (opposite I feel)
Each instantiation of find for something like this is new, so I shan't hazard a direct guess.
Recommendation #1 is to "stage it" and do not execute a move or remove until you've confirmed things.
Use the -mindepth to skip your top level. Find all the files you care about that are of -type f (file), or "*.<extension>".
Once you've verified you "found" all desired, then add the -exec to mv the files up to the top, or instead of mv, use cp so that you do not munch that first try.
Then use it again to find just -type d (directory), validate it finds just the sub-directory names, and then remove those, AFTER you've confirmed that you already have all the movie files at the top level, per your desire.