Windows – Robocopy syntax to copy single file in the same directory with new name

command linerobocopywindows

I need to make a copy of a file:

  1. with all the security (ACL) permissions – that's why I chose robocopy
  2. the copy must be in the same directory with new name obviously

The Robocopy syntax is drastically different from any other command line tools and I don't even know if it is possible to acheive this with robocopy?

What I have tried is:

robocopy c:\temp\ c:temp\ file1.txt file2.txt

however this does not work since this is the sintax to copy the two files listed but since the source & destination are the same the command is ignored… I am not sure it is possible…

Best Answer

Robocopy's primary use case is to mirror or migrate files from one path to a different path. It could be used to copy a single file to a different directory, but it does not rename files. Try the following powershell commands:

copy-item file1.txt file2.txt
get-acl file1.txt | set-acl file2.txt
Related Question