Batch file to move contents of directory, but not the directory itself

Simple solution to the problem.  When using the move command, the directory structure is maintained.  This simple solution is pasted from an incredibly helpful guy named Joseph Styons at Stack Overflow:

move c:\sourcefolder c:\targetfolder

will work, but you will end up with a structure like this:

c:\targetfolder\sourcefolder\[all the subfolders & files]

If you want to move just the contents of one folder to another, then this should do it:

SET src_folder=c:\srcfold
SET tar_folder=c:\tarfold

for /f %%a IN ('dir "%src_folder%" /b') do move %src_folder%\%%a %tar_folder%

pause
shareimprove this answer