Reputation: 1
I am using the below but it is only moving the files and not the folders in the source folder.Is there anything I can add?
move "C:\source\*" "C:\destination\"
Upvotes: 0
Views: 80
Reputation: 70923
@echo off
setlocal enableextensions disabledelayedexpansion
set "source=c:\source"
set "target=c:\destination"
(if not exist "%target%\" md "%target%" ) && (
pushd "%source%" && (
for /f "delims=" %%a in ('dir /a /b *') do move "%%a" "%target%\"
popd
)
)
Ensure that target folder exist, then, if source folder is accesible, change active directory to the source folder, and for each element inside it, execute a move operation to the target folder
Upvotes: 1
Reputation: 41224
This is another way: test it on sample folders first.
robocopy "C:\source" "C:\destination" /move /s
EDIT: Robocopy copies the files and then deletes the original, so will take a long time for large files, even if the source and target locations are on the same hard drive.
Upvotes: 1