Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bat file commands - how to cut file and replace existing file

I need to swap out a file with data (original) to a dummy file with no data. I need to switch back and forth between these tow files on a regular basis. As a safe way to not delete files, I thought the best way would be to rename the original file, then copy the dummy file over to the same directory as the original. WHen i want to switch back I would simply 'cut' the dummy file and then rename the original to its original name. My current scripts look something like this:

pushd "F:\BIO4\Etc\"
ren "omake01.esl" "omake01-OG.esl"
COPY "I:\Mod Switcher\Blank Omake\omake01.esl" "F:\BIO4\Etc\omake01.esl"

1st part done. I have renamed the original so that the dummy file can be copied over to its place in the original directory. Now I want to revert this, and move the dummy file back to where it came from, and then rename my original back to its orignal name:

xcopy /y "F:\BIO4\Etc\omake01.esl" "I:\Mod Switcher\Blank Omake\omake01.esl"
pushd "F:\BIO4\Etc\"
ren "omake01-OG.esl" "omake01.esl"

The problem is here that the file is not being cut, simply copied and then the file is not renamed afterwards. The following output comes up in console:

C:\Users\Anon\Desktop 3>xcopy /y "F:\BIO4\Etc\omake01.esl" "I:\Mod Switcher\Blank Omake\omake01.esl"

F:\BIO4\Etc\omake01.esl
1 File(s) copied

C:\Users\Anon\Desktop 3>pushd "F:\BIO4\Etc\"

F:\BIO4\Etc>ren "omake01-OG.esl" "omake01.esl"
A duplicate file name exists, or the file
cannot be found.

How can i make this easier or actually even work ?

Running Windows & 64 bit

like image 410
Kalamalka Kid Avatar asked Mar 08 '23 03:03

Kalamalka Kid


1 Answers

Instead of copying and renaming, just move the file which is effectively Cut & Paste.

MOVE /Y "I:\Mod Switcher\Blank Omake\omake01.esl" "F:\BIO4\Etc\omake01.esl"

The /Y switch just stops the "confirm overwrite" prompts. Do move /? to see all the switches.

like image 199
Gerhard Avatar answered Mar 22 '23 23:03

Gerhard