Basically moving/sorting multiple files and creating folders corresponding to that file. for example 20180102.txt file has to be moved to corresponding folder 2018\\01\\02 \nWe need a Powershell script that<\/p>\n
\n
reads thru the current directory (where the script resides)<\/li>\n
identifies the correct date that the file represents<\/li>\n
Checks the existing folder structure, if it exists CURRENT FOLDER\\year\\xx monthname\\xx(day). \nExample for file 59_20180102.txt it should go to folder \\2018\\01 January\\02\\<\/li>\n
Creates the folder structure, as needed, for the files CURRENT FOLDER\\year\\xx monthname\\xx(day)<\/li>\n
it should only create folders as needed, meaning for existing files. If I have only one file, it should only create that day folder<\/li>\n
moves each txt file to the appropriate folder \nWhat is the simplest/ most efficient cmdlet/script to do this. Greatly appreciated.<\/li>\n<\/ol>","upvoteCount":5,"answerCount":10,"datePublished":"2018-08-27T19:15:29.000Z","author":{"@type":"Person","name":"fortdru","url":"https://community.spiceworks.com/u/fortdru"},"suggestedAnswer":[{"@type":"Answer","text":"
Advertisement
Basically moving/sorting multiple files and creating folders corresponding to that file. for example 20180102.txt file has to be moved to corresponding folder 2018\\01\\02 \nWe need a Powershell script that<\/p>\n
\n
reads thru the current directory (where the script resides)<\/li>\n
identifies the correct date that the file represents<\/li>\n
Checks the existing folder structure, if it exists CURRENT FOLDER\\year\\xx monthname\\xx(day). \nExample for file 59_20180102.txt it should go to folder \\2018\\01 January\\02\\<\/li>\n
Creates the folder structure, as needed, for the files CURRENT FOLDER\\year\\xx monthname\\xx(day)<\/li>\n
it should only create folders as needed, meaning for existing files. If I have only one file, it should only create that day folder<\/li>\n
moves each txt file to the appropriate folder \nWhat is the simplest/ most efficient cmdlet/script to do this. Greatly appreciated.<\/li>\n<\/ol>","upvoteCount":5,"datePublished":"2018-08-27T19:15:29.000Z","url":"https://community.spiceworks.com/t/need-help-with-powershell-situation/670004/1","author":{"@type":"Person","name":"fortdru","url":"https://community.spiceworks.com/u/fortdru"}},{"@type":"Answer","text":"
Advertisement
There is no out of the box, one size fits all solution for that.<\/p>\n
What have you tried? where are you stuck?<\/p>\n
If you post code, please use the ‘Insert Code’ button. Please and thank you!<\/p>