Situation:
I try to move files inside a loop in shell but my code is not working.
for /D %%F in (*) do (
if \"%%F\" NEQ \"%direct
Try below code to move files from one folder to another in batch script:
for /f %%a in ('dir /a:-D /b') do move /Y "%%~fa" "%directoryToPutFilesIn%"
Explanation :
dir /a:-D /b : This command will list all files in the directory
move /Y "%%~fa" "%directoryToPutFilesIn%" : This will move all files in the directory where this command is executed to the destination you have mentioned.
%%~fa : This command will get full qualified path of the file with it's name.
Try Below code Move directories : Below command will move directories in the Path where this command is executed to the destination provided. In this that will be H:\ Drive, Change it accordingly
for /D %%b in (*) do move /Y "%%~fb" "H:\"