Dos command to cut files and paste

Asatoma Sadgamaya
Asatoma Sadgamaya used Ask the Experts™
on
Hi,

I am searching for a dos command which can cut files from a given folder and paste those files in to an Archive folder which sits along side with the files need to be uploaded into. There are folders with space in its name. I have to insert this command in a bat file. I use below code for my other tasks and its working fine, but it does not do cut and paste, it does copy and paste.

@echo off
setlocal

echo Start Copy

set SOURCE_DIR=C:\Nat\Reports\Reports
set DEST_DIRS="X:\", "N:\Reports\Production Repts\Reports"
set FILENAMES_TO_COPY="2018All Projects_New.xlsx","2017Report_New.xlsx"

pushd "%SOURCE_DIR%"

for %%F in (%FILENAMES_TO_COPY%) do (

    for %%D in (%DEST_DIRS%) do (
        echo file "%%~F" to "%%~D"
        xcopy /Y "%%~F" "%%~D"
    )

)

popd

echo. Done.
exit /b

Thank you
A
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
AlexSenior Infrastructure Analyst

Commented:
Move source destination

Nice and easy :D
Jeremy WeisingerSenior Network Consultant / Engineer

Commented:
As Alex says, use the move command. Here's the syntax
move "C:\Source with space" "C:\Dest with space" /Y

Open in new window

Author

Commented:
Hi Jeremy and Alex,

Thanks for your feedback, I really appreciate it.  I have edited my requirement.

(Jeremy the code you gave is not working for me. I have done a test based on what you have mentioned.)

move "C:\Users\A1\Desktop\kk" "C:\Users\A1\Desktop\kk\bb b" /Y

Please have a look.

Thank you
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

Senior Network Consultant / Engineer
Commented:
Sorry, my fault. I put the /Y in the wrong location. Also, it gets a little tricky if you're moving things into a sub folder of itself. See if this works for you:
md "C:\Users\A1\Desktop\kk\bb b"
move /Y "C:\Users\A1\Desktop\kk\*" "C:\Users\A1\Desktop\kk\bb b"

Open in new window

Author

Commented:
Thanks Jeremy, that worked for me.

2 updates

1. I did *.xlsx*

md "C:\Users\A1\Desktop\kk\bb b"
move /Y "C:\Users\A1\Desktop\kk\*.xlsx*" "C:\Users\A1\Desktop\kk\bb b"

2. I change move to copy for another work. that worked

copy /Y "C:\Users\A1\Desktop\kk\*.xlsx*" "C:\Users\A1\Desktop\kk\bb b"

Thank you so much
Jeremy WeisingerSenior Network Consultant / Engineer

Commented:
Glad to help. :)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial