[Win 8.x] Robocopy and same directory

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
balubeto
Posts: 136
Joined: 08 Dec 2011 12:14

[Win 8.x] Robocopy and same directory

#1 Post by balubeto » 20 Oct 2014 02:01

Hi

With the Robocopy command of Windows 8.x, how do I do a copy of a file (renaming it) in the same directory of the source file?

Thanks

Bye

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: [Win 8.x] Robocopy and same directory

#2 Post by foxidrive » 20 Oct 2014 02:26

This doesn't use robocopy:

Code: Select all

copy "d:\source\file.bin" "d:\source\file.new"

Yury
Posts: 115
Joined: 28 Dec 2013 07:54

Re: [Win 8.x] Robocopy and same directory

#3 Post by Yury » 20 Oct 2014 03:13

Code: Select all

@echo off

set "dir=D:\Test"
set "source=example.txt"
set "dest=new.txt"

pushd "%dir%"
>nul robocopy . temp "%source%"
>nul move "temp\%source%" "%dest%"
rd temp
popd

exit /b

Post Reply