I wrote a simple script to delete useless files from a directory using the find
command.
Now I'm wondering if I can add lines to the script to flatten directories, but not completely flattened.
e.g.,
If I have a big directory named cleantarget
:
- cleantarget
- Folder A
- Folder A1
- Folder A2
- Folder B
- Folder B1
- Folder B11
- Folder B1
- Folder A
I want the end result to be:
- cleantarget
- Folder A
- Folder B
I do NOT want the result to be:
- cleantarget
- all my files
There are 16000 files in this directory, so it'd be nice to do this with a script, so I can run it occasionally when the directory gets messed up again.
How do I do this?
EDIT: In essence, this means: I want a script, that will separately flatten each sub-directory within a given target directory. i.e., flatten Folder A, flatten Folder B, and flatten Folder C, and so on until all directories within cleanfolder
are flattened.
directory A
, andflatten directory B
etc.? – ctrl-alt-delor Jun 22 '19 at 16:56rm
? – jesse_b Jun 23 '19 at 00:05for
-loop around a piece of code. – Kusalananda Jun 23 '19 at 06:51