0

I'm trying to take a .txt file and move it over the network with xcopy.

Here is my code thus far:

@ECHO off
XCOPY /y pushd \\Oafrpnbtcsi01\Test_Systemplatz\Systemplatz_SLOT_1_Fail.txt

rem get date, make if file name friendly
FOR /F "tokens=1-4 delims=/ " %%i in ('date/t') do set d=%%i-%%j-%%k-%%l

set MBD=Systemplatz_SLOT_1_FailB%d%DN.txt
ren Systemplatz_SLOT_1_Fail.txt %MBD%
move *.txt F:\Public\Logfiles\Systemplatz\Test\02\Systemplatz Slot 1
@ECHO on

I also want the date to be added into the text file's name.

So far it's not working, so I'm positive I have done something wrong. If there is a better way to do this, please do explain.

4
  • It would help if you provided a sample of the txt file and the corresponding converted csv file.
    – DavidPostill
    Commented Mar 21, 2016 at 9:25
  • @DavidPostill added a sample. Commented Mar 21, 2016 at 9:33
  • And the equivalent csv file?
    – DavidPostill
    Commented Mar 21, 2016 at 9:34
  • Give me a few to Recompile my question. Commented Mar 21, 2016 at 9:39

1 Answer 1

1

I see two problems. First, there's this line:

XCOPY /y pushd \\Oafrpnbtcsi01\Test_Systemplatz\Systemplatz_SLOT_1_Fail.txt

pushd is a command in and of itself; it can't be passed as an argument to xcopy. xcopy needs two arguments, a source and a destination; it looks like you only have one. I'm guessing - but I am not sure - that you wanted to move the current directory to \\Oafrpnbtcsi01\Test_Systemplatz\, which contains the file you're going to work with. To do that, replace the above line with just this:

pushd \\Oafrpnbtcsi01\Test_Systemplatz\

The second issue is on this line:

move *.txt F:\Public\Logfiles\Systemplatz\Test\02\Systemplatz Slot 1

It looks like one of the folders in the path is called Systemplatz Slot 1, but to move, Slot and 1 look like different arguments because there are spaces. You should enclose the whole destination path in quotes, like this:

move *.txt "F:\Public\Logfiles\Systemplatz\Test\02\Systemplatz Slot 1"

Finally, you probably want a popd at the end of the script to reverse the pushd, taking the current directory back to its original place.

1
  • Awesome thank you was driving me nuts last night. Commented Mar 21, 2016 at 18:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .