1.

Solve : Command vs Batch file?

Answer» <html><body><p>I am using the MOVE command, but running in to a problem.  If I put the command in to a Command <a href="https://interviewquestions.tuteehub.com/tag/window-11540" style="font-weight:bold;" target="_blank" title="Click to know more about WINDOW">WINDOW</a> it works fine, but from a batch file I get errors.  Why?  I am running on a Windows 7(64 bit).<br/><br/>move /Y C:\#CAMS\Download\DST_exe\*.* C:\%Backup\DST\<br/><br/>If I use this at a DOS prompt it works great.  <br/>If I use it in a batch file I get the messages "Cannot move multiple files to a single file"<br/><br/>Both folders do exist, and there are multiple files in them.<br/><br/>Maybe there is a better way.  What I am doing is moving file I download then extract files from (exe files and zip files)  to a different directory.  For example, all DST Files are an EXE file that is then ran and put in a 'DST_Work' folder for the <a href="https://interviewquestions.tuteehub.com/tag/database-11539" style="font-weight:bold;" target="_blank" title="Click to know more about DATABASE">DATABASE</a> to <a href="https://interviewquestions.tuteehub.com/tag/process-11618" style="font-weight:bold;" target="_blank" title="Click to know more about PROCESS">PROCESS</a>.  I clear the 'Work" folder, but I want to archive the files in the "DST_exe" folder.  I have 5 vendors like this.  Some are exe, some are zip, and another uses a different format.<br/><br/>Any advice is appreciated.<br/><br/>MichaelThere's a number of syntax problems with your line of code.<br/><br/>% needs to be escaped as %%. Better yet, you shouldn't use this character in folder or file names...<br/><br/>You should also surround your paths with <a href="https://interviewquestions.tuteehub.com/tag/quotation-1175219" style="font-weight:bold;" target="_blank" title="Click to know more about QUOTATION">QUOTATION</a> marks, so the command doesn't screw up when it encounters a space.<br/><br/>move /Y "C:\#CAMS\Download\DST_exe\*.*" "C:\%%Backup\DST\"<br/><br/>If Backup is supposed to be an expanded variable, it's because you forgot the second %.<br/><br/>move /Y "C:\#CAMS\Download\DST_exe\*.*" "C:\%Backup%\DST\"<br/><br/>You see, % is <a href="https://interviewquestions.tuteehub.com/tag/used-763273" style="font-weight:bold;" target="_blank" title="Click to know more about USED">USED</a> in expanding DOS variables.</p></body></html>


Discussion

No Comment Found