mardi 31 octobre 2017

Batch file to search multiple subdirectories for file/folder, if found, copy that subdirectory to another location

Firstly, I apologise for the lack of preliminary code. I am very novice at this stuff. I have spent a few hours Googling and tried a few different things however, nothing is working out. I didn't think there was much point copy pasting something here, which may be on completely the wrong track. If, despite that, you're interested in my query, please read on.

I am wanting to search all sub-folders under a specific folder for another folder/file/file extension and if that file/folder exists, copy the folder to another location. The Folder structure, up to the point where the file or folder is found would need to be intact (with only the folders necessary to get to that folder).

Example folder structure:

\Drive1

\\Folder123
\\\FodlerA
\\\\Folder!
\\\\Folder@
\\\\Folder#

\\Folder456
\\\\FolderA
\\\\Folder!
\\\\Folder$
\\\\Folder#

\\Folder789
\\\FolderA
\\\\Folder!
\\\\Folder@
\\\\Folder%

Let's say I wanted to search Drive1 for every instance of Folder@ and then copy that folder (and contents) to a new location with the necessary folders to get to Folder@.

So I would end up with something like:

Drive2:
Folder123/FolderA/Folder@
Folder789/FolderA/Folder@

If the in-between folders were excluded and I just ended up with:

Folder123/Folder@
Folder789/Folder@

This would suffice.

Is something like this possible? Any guidance would be appreciated.

Aucun commentaire:

Enregistrer un commentaire