Windows Script with Jscript error trying to move file

i get the following error when running the script provided below  the ciopy part works perfect the move part is the one that gives the error please help

Line 23
Char  2
Error  The system cannot find the file specified.

code 80070002
source (null)


this is the script please help



// Copy compressed backups to backups server then move originals to data folder.
// Plese note: all backslash's must be doubled, this is a becouse of the way Jscript deals with strings

//--S-p-e-c-i-f-y--t-h-e--P-a-t-h----------
var strPath = "Y:\\TransCompCasino\\";
var strDestPath = "\\\\backups\\DBbackups\\TransCompCasino\\";

var shell = new ActiveXObject("WScript.Shell");
var objFSO = new ActiveXObject('Scripting.FileSystemObject');

var objFolder = objFSO.GetFolder(strPath);
var nrFiles = objFolder.Files.Count;
var collectionFiles = new Enumerator(objFolder.Files);
while (!collectionFiles.atEnd())
  {
   objFile = collectionFiles.item();
   if (objFile.Type == "RAR File")
     {
      strFileName = objFile.Name;
                strCommand = "xcopy " + strPath + strFileName + " " + strDestPath + " /v /d";
      shell.Run(strCommand,0,true);
      strCommand = "move /y " + strPath + strFileName + " " + strPath + "data\\";
      shell.Run(strCommand,0,true);
     }
   collectionFiles.moveNext();
  }
m3mn0ckAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

browolfCommented:
Hi m3mn0ck,


print the strcommand to the screen after you've constructed it. this should help you know why it doesnt work.
0
m3mn0ckAuthor Commented:
The string is working fine, actually if i just change the Move Comand to Xcopy (of course i remove the /y switch it works fine and copies the files. but it will not move them i get that error even if i run it without the /y switch
0
browolfCommented:
have you  tried using proper jscript filesystem object stuff to do the move e.g.

Sub ManipFiles
  Dim fso, f1, f2, s
  Set fso = CreateObject("Scripting.FileSystemObject")
  Set f1 = fso.CreateTextFile("c:\testfile.txt", True)
  Response.Write "Writing file <br>"
  ' Write a line.
  f1.Write ("This is a test.")
  ' Close the file to writing.
  f1.Close
  Response.Write "Moving file to c:\tmp <br>"
  ' Get a handle to the file in root of C:\.
  Set f2 = fso.GetFile("c:\testfile.txt")
  ' Move the file to \tmp directory.
  f2.Move ("c:\tmp\testfile.txt")
  Response.Write "Copying file to c:\temp <br>"
  ' Copy the file to \temp.
  f2.Copy ("c:\temp\testfile.txt")
  Response.Write "Deleting files <br>"
  ' Get handles to files' current location.
  Set f2 = fso.GetFile("c:\tmp\testfile.txt")
  Set f3 = fso.GetFile("c:\temp\testfile.txt")
  ' Delete the files.
  f2.Delete
  f3.Delete
  Response.Write "All done!"
End Sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows 2000

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.