I have a batch script to copy a file to another destination. I am trying to copy file while keeping its name and extension, then change it all in the destination folder. However, destination folder will always have the same file name with different extension after changes. That is why I want to overwrite the current file in any situation after changing copied file's name and extension. In the sample, file to be copied is "My File Name.ssl" and destination file that will be overwritten after change is "renamedfile.conf". This code does not even copy the file.
@echo off
move /Y C:\Users\Murray\Desktop\My File Name.ssl C:\Program Files (x86)\Folder\Subfolder\
ren "C:\Program Files (x86)\Folder\Subfolder\My File Name.ssl" renamedfile.conf
What am I missing?
You are missing the correct quotes around filenames
Using move with the correct rights you will not need to rename as a secondary function, see usage with move /?
move /Y "C:\Users\Murray\Desktop\My File Name.ssl" "C:\Program Files (x86)\Folder\Subfolder\renamedfile.conf"
will move it with the new name
But you need admin rights for "C:\Program Files (x86)" so may need to run cmd as administrator.
Without admin rights
move /Y "C:\Users\Murray\Desktop\My File Name.ssl" "C:\Program Files (x86)\Folder\Subfolder\"
in my case gives Access is denied. 0 file(s) moved.
If you wish to keep the original copy and just replace the one in program files then check using copy /?
but in this case simply just replace move
with copy