1.

Solve : Create a folder prior to moving files??

Answer» <html><body><p>I <a href="https://interviewquestions.tuteehub.com/tag/got-23540" style="font-weight:bold;" target="_blank" title="Click to know more about GOT">GOT</a> the following code:<br/><br/> Code: <a>[Select]</a>for /f "tokens=*" %%c in ('dir "C:\Source <a href="https://interviewquestions.tuteehub.com/tag/folder-246959" style="font-weight:bold;" target="_blank" title="Click to know more about FOLDER">FOLDER</a>" /a:-d /s /<a href="https://interviewquestions.tuteehub.com/tag/b-236590" style="font-weight:bold;" target="_blank" title="Click to know more about B">B</a>') do <a href="https://interviewquestions.tuteehub.com/tag/move-548879" style="font-weight:bold;" target="_blank" title="Click to know more about MOVE">MOVE</a> /y "%%c" "C:\Destination folder"<br/><br/>rd /s /q "C:\Source folder"<br/><br/>It empties all files from the Source folder as well as its sub folders.<br/>It then deletes the Source folder and its remaining subs.<br/><br/>How can I tell it to create the destination folder if it doesn't already exist prior to moving the files? Code: <a>[Select]</a>if not exist "C:\Destination folder" md "C:\Destination folder"Right, but where in that first line would I put it?You would put it before the first line, which will now be the second line.<br/>Right...<br/>Stupid me... <br/><br/><br/>I was <a href="https://interviewquestions.tuteehub.com/tag/thinking-771898" style="font-weight:bold;" target="_blank" title="Click to know more about THINKING">THINKING</a> it needed to be in the middle somewhere since the code had already grabbed the files out of their folders...If you want to move a file from folder A to folder B, it is necessary to first ensure that folder B exists. Before you even start.Yeah, brain fart on my part I suppose... <br/><br/>In my defense, I copy/pasted the code from elsewhere...</p></body></html>


Discussion

No Comment Found