I have one folder that has inside of it 53 different folders. Inside of each of the 53 folders is 10 files, five video and five text files. I would like to create one folder that contains the files of 50 folders but only the files and I do not wish for them to be separated into folders, only one big folder with all 530 files. At the same time, I do not want to change in any way the original folder setup. So, I want all the links to point to the same one folder with no sub-folders.
I was speaking with someone else about this and this is what they recommended:
PS C:\> Get-ChildItem .\foo -Recurse -Attributes !Directory | Copy-Item -Destination .\bar
Use this Powershell command to recursively copy all files from a given root folder to a single destination folder. This will flatten the file hierarchy. Then, pipe the output to a function that creates hard links, such as the one described here.
I told him that I have never even heard of Powershell. But I did read about it for a little bit and this is what I came up with:
PS I:\> Get-ChildItem .\Music\Music 1 -Recurse -Attributes !Directory | Copy-Item -Destination .\Music\new folder
But there is an issue. The folder "Music 1" has the 53 folders but for two of the 53 folders (the first one and the last one), I need to have the individual files located beside the new folder that we are creating. (but not inside)
Basically, I don't know what I'm doing here but I'm trying. But it seems like I need to do three things. One, do the Powershell command. Two, create a function that creates hard links. Three, pipe the output of the powershell command to the function. How do I do this once and for all please? Thank you