Script to keep only the last three directories under each of the subdirectory

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Script to keep only the last three directories under each of the subdirectory



Assume that I have a directory structure as follows:



applications

├── configs
│ ├── 1.0.0.1
│ └── 1.0.2.1

├── logs
│ ├── l1.0.3
│ └── l2.0.4

└── src
├── s1.p.8
├── s1.p.9
└── s2.p.10
Now I want to delete the folders under each subdirectory under applications directory and keep only the last three under each subdirectory
Eg: under applications directory we have like configs, logs,src, test, etc.
The requirement is that I need to keep only the last three directories under each of these directories(configs, logs,src, test, etc).
Thanks.









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Visual Studio Code: How to configure includePath for better IntelliSense results

Spring cloud config client Could not locate PropertySource

Regex - How to capture all iterations of a repeating pattern?