I have parent folder includes sub folders. In every sub folder I have folders as follow:
Parent_folder folder1 folder_01_PAP_515151 folder_02_PAPA_554651 folder_03_PAPX_541313 folder_04_PAP_654123 folder2 folder_20_PAP_413513 folder_02_PAPD_521354 folder_055_PAP_685413 folder_100_PAP_132312 folder3 folder_11_PAPE_5313351 folder_32_PAP_3513131 folder_53_PAP_3213321 folder_84_PAP_3313213
I used the following command to list all the folders and sub folders that contain "PAP" and save it in a text file "list.txt"
find -type d -name "*_PAP_" > list.txt
The output was as follow:
./folder1/folder_01_PAP_515151 ./folder1/folder_04_PAP_654123 ./folder1/folder_20_PAP_413513 ./folder2/folder_055_PAP_685413 ./folder2/folder_100_PAP_132312 ./folder3/folder_32_PAP_3513131 ./folder3/folder_53_PAP_3213321 ./folder3/folder_84_PAP_3313213
From this list, I want to create new folders and the names of these new folders must contain the parts "three digits_PAP" e.g "055_PAP", "32_PAP", "53_PAP", ... from the previous list. The list of new generated folders must be:
01_PAP 04_PAP 20_PAP 055_PAP 100_PAP 32_PAP 53_PAP 84_PAP