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

Arduino Mega cannot recieve any sketches, stk500_recv() programmer is not responding

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

C++ virtual function: Base class function is called instead of derived