Reputation:
I need to do a .bat copy of a .sh, I don't know much Windows cmd. On Linux I could do
mv ...
or
rsync -a SOURCE/ DEST/ --remove-sent-files --ignore-existing --whole-file
but Windows "move" can't do the same
maybe there is a windows simple alternative, simpler and more performant than
for /R c:\sourceFolder\ %%G in (*) do ( move /Y "%%G" c:\destinationFolder\ )
Linux mv seems to update directories pointer, but the above Windows command will do hard stuff? I guess it's not a good idea for the big folders I need to frequently move
Upvotes: 13
Views: 51153
Reputation: 2260
I don't have a one liner, but here's what I did using CMD and Notepad++...
F:> DIR /S /B > moveit.bat This gives you all your file names
Use Notepad++ to edit the bat file Replace with Regular Expression, search for ^(.+?)$ and replace with MOVE "$1" %DESTDIR% Save, exit
Execute your batch file.
Upvotes: 0
Reputation: 21
I know this is an old thread, but since it does not have a correct answer I figured I'd tie it off.
The old DOS command to accomplish this is:
move <source directory> <destination directory>
So in the OP question:
move C:\sourceFolder c:\destinationFolder
The folder and everything in the folder (including sub-directories) will be moved.
Upvotes: 2
Reputation: 1
@echo off
setlocal
set DIR=
set OUTPUTDIR=C:\Documents and Settings\<username>\Desktop\sandbox1\output
for /R %DIR% %%a in (*.jpg) do xcopy "%%a" "%OUTPUTDIR%"
Upvotes: 0
Reputation: 5
For recursive move in windows, a simple move
command is ok. Here is the example, I think it would be helpful.
move D:\Dbbackup\*.dmp* D:\Dbbackup\year\month\
Where .dmp
is the extension of the file that would be moved to the location recursive folder Dbbackup , then year, then month.
Upvotes: -2
Reputation: 19956
Robocopy did wonders for me:
robocopy c:\cache c:\cache-2012 ?????-2012*.hash /S /MOV
I used it to move all files with certain mask out of c:\cache
and its numerous subdirectories.
Upvotes: 19
Reputation: 45173
The move
command can move directories as well as files.
cd /d C:\sourceFolder
rem move the files
for %%i in (*) do move "%%i" C:\destinationFolder
rem move the directories
for /d %%i in (*) do move "%%i" C:\destinationFolder
Upvotes: 12
Reputation: 139
XCOPY should do the trick, I use it it in batch files all the time
something like, if you're just trying to target .sh files
XCOPY /E /H /Y /C "%SOURCEDIR%\*.sh" "%TARGETDIR%"
Let me know if you have more questions
Upvotes: 1