Hello everyone in the python community, I’m very new to programming and if anyone can help me, in the future I want to be able to repay the kindness. I’m not an expert as I mentioned before, but I have a first idea for the logic of the script to begin. I can’t say whether what I think would be the best way to do it, so I’m asking for everyone’s help.
The script proposal:
Select a directory, within this directory there are several folders and subfolders, you need to find a certain extension, rename it and move it.
Challenge:
Imagine that “directory_x” has several “folders_a, folders_b, folders_c…”
Within these folders there are several subfolders. My challenge is finding a specific “extension.y”, copying it, moving it with the same name as “folders_a, folders_b, folders_c…”, not using the subfolder names. Within the “directory_x” the “folders_a, folders_b, folders_c…” are organized, but the subfolders are not organized. This is why I need a script for myself.
Process:
- Process 1: Select a specific directory (we can call it “directory_x”), with several folders (we can call them “folders_a, folders_b, folders_c…”), and within each folder there are several subfolders and files archiver (*zip, *rar, etc.)
- Process 2: Find all compressed files within “directory_x”. Extract these files to the same original location, in a folder with the same name. Example Nome-01.zip, extract and create folder Nome-01 and keeping the location where the zip or rar file was found.
- Process 3: Find files with “extension.y”, copy it and move it to “directory_x”, keeping the name of “folders_a, folders_b, folders_c…” where it was found. Example: “folder_a” file of “extension.y” was found, rename it to “folder_a.y” and move it to the selected direct “directory_x”'. If there is more than one “extension.y” file within a subfolder, rename it and copy it, adding a character to not subscribe.
Print result would be:
- directory_x
- folder_a
- folder_b
- folder_c
- folder_a.y
- folder_b.y
- folder_c.y
- folder_c1.y
- folder_c2.y