I wrote a script lately for move files and folders into another specific folder. \nMore precisely the script searches files and folders which are older than 30 days and move them to another folder. \nExemplary:<\/p>\n
In the folders are many files. The folder 1-30 days is the destination of the script. Files and folders which are older than 30 days should be moves to 1-30 days (/move - so deleting at the source after).<\/p>\n
To put it simple I start testing it under easy conditions without /MINAGE and just 3 folders with empty files. I use the following robocopy command:<\/p>\n
Now we come to the core, my problem: \nOn the first run the script does not move the folders into 1-30 Days. Just the files and it “copies” the folders like mirroring but delete the files on the source (like I want to). \nThe empty folders remain. Just on the second run with empty folders now it moves the folders too… \nWhat is wrong with my script?<\/p>\n
I hope I could make it understandable \nThanks for your help!<\/p>","upvoteCount":6,"answerCount":11,"datePublished":"2018-08-29T04:11:47.000Z","author":{"@type":"Person","name":"rodjunior9","url":"https://community.spiceworks.com/u/rodjunior9"},"suggestedAnswer":[{"@type":"Answer","text":"
Good day!<\/p>\n
I have a question about robocopy:<\/p>\n
I wrote a script lately for move files and folders into another specific folder. \nMore precisely the script searches files and folders which are older than 30 days and move them to another folder. \nExemplary:<\/p>\n
In the folders are many files. The folder 1-30 days is the destination of the script. Files and folders which are older than 30 days should be moves to 1-30 days (/move - so deleting at the source after).<\/p>\n
To put it simple I start testing it under easy conditions without /MINAGE and just 3 folders with empty files. I use the following robocopy command:<\/p>\n
Now we come to the core, my problem: \nOn the first run the script does not move the folders into 1-30 Days. Just the files and it “copies” the folders like mirroring but delete the files on the source (like I want to). \nThe empty folders remain. Just on the second run with empty folders now it moves the folders too… \nWhat is wrong with my script?<\/p>\n
I hope I could make it understandable \nThanks for your help!<\/p>","upvoteCount":6,"datePublished":"2018-08-29T04:11:47.000Z","url":"https://community.spiceworks.com/t/robocopy-move-dont-move-folders-on-first-run/670299/1","author":{"@type":"Person","name":"rodjunior9","url":"https://community.spiceworks.com/u/rodjunior9"}},{"@type":"Answer","text":"
I think that the directory’s are still in use when robocopy wants to remove them. You could try a retry /r:3 /w (wait time is 30 seconds by default).<\/p>\n
Also, is the log options telling you something?<\/p>","upvoteCount":0,"datePublished":"2018-08-29T05:13:49.000Z","url":"https://community.spiceworks.com/t/robocopy-move-dont-move-folders-on-first-run/670299/2","author":{"@type":"Person","name":"iqsolutions","url":"https://community.spiceworks.com/u/iqsolutions"}},{"@type":"Answer","text":"