I need to move and rename a file but for reasons I'm not going into can't use SSIS or DTS. I'm trying to use xp_cmdshell and getting the message "The syntax of the command is incorrect". I'm using examples I've found on line and am confused as to what I've done wrong. The rename should add the date onto the filename, for example EandWTest.txt should be moved to an archive folder and renamed EandWTest_0110523_16_07.txt.
This is the code I've found and am trying to fit my needs, I'm not actually using the variables to stipulate the filename and path but will do that when I've got the basic code working:
asked May 23 '11 at 07:55 AM in Default
You are missing quotes around the path. You have spaces in the folder names and windows command line doesn't like that. Just put double quotes around the filenames to fix that.
Also the value of @NewFileName is a bit messed up, just running the print command returned:
So the .txt part at the end is not quite right.
So you want the command to end up looking like this:MOVE /Y "C:\Auto Import\Auto Import\EandWTest.txt" "C:\Auto Import\Auto Import\Archive\EAndWTest.200110523_17_13.txt"