Hi all, I am a newbie in Powershell and tried my luck the last couple of days but haven’t really managed to get a script sorted. I know how to search for files recursively but don’t really know how to move them to their respective folder . Here is my issue . Root Folder c:\\temp has multiple empty subfolders Called Test1 Test2 Test3 but also has other folders that contain files Test1file Test2file Test3file What I want to achieve is to look into all subfolders that contain files and move them to their respective folders Test1file->test1folder and then delete the empty subfolders .<\/p>\n
Advertisement
Any help would be greatly appreciated .<\/p>","upvoteCount":9,"answerCount":6,"datePublished":"2019-06-18T04:49:02.000Z","author":{"@type":"Person","name":"voluntas90","url":"https://community.spiceworks.com/u/voluntas90"},"suggestedAnswer":[{"@type":"Answer","text":"
Advertisement
Hi all, I am a newbie in Powershell and tried my luck the last couple of days but haven’t really managed to get a script sorted. I know how to search for files recursively but don’t really know how to move them to their respective folder . Here is my issue . Root Folder c:\\temp has multiple empty subfolders Called Test1 Test2 Test3 but also has other folders that contain files Test1file Test2file Test3file What I want to achieve is to look into all subfolders that contain files and move them to their respective folders Test1file->test1folder and then delete the empty subfolders .<\/p>\n
Any help would be greatly appreciated .<\/p>","upvoteCount":9,"datePublished":"2019-06-18T04:49:02.000Z","url":"https://community.spiceworks.com/t/move-files-to-their-respective-folders/716845/1","author":{"@type":"Person","name":"voluntas90","url":"https://community.spiceworks.com/u/voluntas90"}},{"@type":"Answer","text":"
I guess you have to compare names or something for powershell to know where where you want it to go.<\/p>\n
What have you tried so far? Feel free to share your code and we’ll look over it<\/p>\n
If you post code, please use the ‘Insert Code’ button. Please and thank you!<\/p>\n