Jump to content
  • GUESTS

    If you want access to members only forums on HSO, you will gain access only when you Sign-in or Sign-Up .

    This box will disappear once you are signed in as a member. ?

Any DOS command experts out there?


Recommended Posts

I have a large amount of files to move from one directory to another. I have been doing this with batch files since it is easier that cutting and pasting. My question is does anyone know how to get a log file of the files moved and any errors that may have ocurred during the move?

Example:

move /y C:\folder1\file.txt D:\folder2\file.txt

I am guessing I could use a pipe "|" and then output to a text file but I haven't been able to figure out the syntax to pull it off. I have searched the internet but have had no luck finding the information I need.

Link to comment
Share on other sites

OK to redirect a list of a directory the command was:

C:\Users\Scott>dir >test.txt

The output in the file was: But bear in mind it is going to silence the output on your screen and send it to the file only, so you aren't going to see a thing.

Volume in drive C has no label.

Volume Serial Number is 045E-96CF

Directory of C:\Users\Scott

12/10/2009 05:11 AM <DIR> .

12/10/2009 05:11 AM <DIR> ..

10/06/2009 05:38 PM <DIR> Contacts

11/17/2009 08:39 PM <DIR> Desktop

12/07/2009 05:52 AM <DIR> Documents

12/05/2009 12:19 PM <DIR> Downloads

08/06/2009 05:32 AM <DIR> Favorites

08/01/2009 08:06 AM <DIR> Links

08/01/2009 08:06 AM <DIR> Music

08/01/2009 08:06 AM <DIR> Pictures

09/05/2009 02:33 PM <DIR> Saved Games

08/01/2009 08:06 AM <DIR> Searches

12/10/2009 05:14 AM 0 test.txt

08/01/2009 08:06 AM <DIR> Videos

1 File(s) 0 bytes

13 Dir(s) 229,454,495,744 bytes free

Is that what you are looking for.

Link to comment
Share on other sites

No not quite what I want but , thank you. When the files are moving from one folder to the other I want to record a list of errors if there are any. The "/Y" tells the move command not to over write the file if it exists. This would be an error in moving the files so in lieu of displaying on screen "file11.txt exists" I want it to write that line to a text file so I can review the list once all the files are moved.

Link to comment
Share on other sites

The redirect just writes what would normally be echoed on the screen to a text file. So a simple >failure.txt at the end of your command would write would normally be shown on your screen to the failure.txt file. If I am reading what you want that is the ticket.

My dir command would have echoed the contents of the local folder to the screen, but instead I echoed the contents to a file. What I showed in the contents was what was written to the file instead of echoed on the screen.

Link to comment
Share on other sites

upnorth is right. You can add '> filename' to any DOS command to send the output to a file instead of the screen.

move /y C:\folder1\file.txt D:\folder2\file.txt > C:\logfile.txt

You can also use '>> filename' if you want to append the output to the file, instead of creating a new file.

Link to comment
Share on other sites

Thanks for the help. That does work for recording the command, it does not record and errors generated. I am guessing the error reporting needs to be written in the batch file somewhere. I finished moving my files now. I'll just do a directory compare to see what didn't get moved.

Link to comment
Share on other sites

It is only going to record what was echoed on the screen and if you suppressed that with the /y switch, there will be nothing echoed to write to the file. To get the errors you would need to remove the /y and then respond to any errors with a y or n to make this work but if you have a real lot of errors to deal with.

Link to comment
Share on other sites

Can you use robocopy? It's a utility made available from Microsoft, short for Robust File Copy. You'll find it as a standard with the windows vista/7/2008 series of OS, otherwise it is part of the windows resource kit you can download.

I typically use robocopy for cross network transfers as you can force retries on failures and a bunch of other neat tricks. It will also let you dump a log file of a full report, to include any errors that occured. The end of the log will include a summary of successful/failures, total number of files and directories.

Here's the command I normally use:

\>robocopy "c:\sourcedir" "d:\destdir" /E /COPYALL /LOG:c:\logfile.txt

You can throw in /R:XX for any number of retries and /W:TT for time to wait between retries. In your situation, you can also add the /MOVE flag to move the files rather than copy.

Let me know if this will work for you, otherwise i've got a couple other techniques if you want to keep it to DOS-only commands.

Link to comment
Share on other sites

Join the conversation

You can post now ↓↓↓ or ask your question and then register. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.