

InterviewSolution
Saved Bookmarks
1. |
Solve : Batch Script Question? |
Answer» <html><body><p>Let's say I do a simple clean up command like:<br/><br/>cd c:\users\username\desktop<br/><br/>move *.jpg c:\Images<br/><br/>Let's say some files were moved, is there any way to record that to a log?<br/>Like have it look like:<br/><br/>Image1.jpg moved to [C:\Images]<br/>Image2.jpg moved to [C:\Images]<br/><br/>You can't just echo move *.jpg C:\Images > Log.log can you?<br/>And also, let's say it didn't move anything. Could I record that too?<br/><br/>All help appreciated.<br/><br/> ~SacredUse the <a href="https://interviewquestions.tuteehub.com/tag/redirector-7272638" style="font-weight:bold;" target="_blank" title="Click to know more about REDIRECTOR">REDIRECTOR</a> '>' '>>'<br/>move *.jpg c:\Images >> C:\Somefile.ext<br/><br/>a single > will start a new file basically<br/>a >> will append<br/><br/>My bad I hadn't looked at your whole structure it should be like<br/><br/>move "C:\Images\*.txt" 01\ >> 01\Somefile.txt<br/>I wrap my directory commands just to be safe.. but with no spaces in the dir names it wouldn't be necc.. the folder to be moved to ie. 01\ doesn't need an extension if your not changing them.. finally you can out put your Results anywhere just remember if the distination folder has spaces in any Dir name wrap it...<br/><br/>Usually in a case of recording and not.. I just use a '<br/>if exist C:\ balh <a href="https://interviewquestions.tuteehub.com/tag/bla-399162" style="font-weight:bold;" target="_blank" title="Click to know more about BLA">BLA</a>\*.jpg (<br/>move......<br/>) else (<br/>someother command<br/>) Quote from: pfmk2 on <a href="https://interviewquestions.tuteehub.com/tag/august-385421" style="font-weight:bold;" target="_blank" title="Click to know more about AUGUST">AUGUST</a> 01, 2010, 09:27:03 PM</p><blockquote>Use the redirector '>' '>>'<br/>move *.jpg c:\Images >> C:\Somefile.ext<br/><br/></blockquote> <br/>that will not log anything. move does not give you a stdout when it moves <a href="https://interviewquestions.tuteehub.com/tag/successfullybrbr-3084898" style="font-weight:bold;" target="_blank" title="Click to know more about SUCCESSFULLY">SUCCESSFULLY</a>.yeah I know that.. <a href="https://interviewquestions.tuteehub.com/tag/maybe-2821687" style="font-weight:bold;" target="_blank" title="Click to know more about MAYBE">MAYBE</a> if ya actually read the rest.........................<br/><br/>well when it successfully moved on my machine it recorded just fine as<br/>C:\Tests\01\Fri.txt<br/>C:\Tests\01\Mon.txt<br/>C:\Tests\01\Sat.txt<br/>C:\Tests\01\Sun.txt<br/>C:\Tests\01\Thu.txt<br/>C:\Tests\01\Tue.txt<br/>C:\Tests\01\Wed.txt<br/> Code: <a>[Select]</a><br/>S:\>echo hello>test1.txt<br/><br/>S:\>echo hello>test2.txt<br/><br/>S:\>echo hello>test3.txt<br/><br/>S:\>echo hello>test4.txt<br/><br/>S:\>echo hello>test5.txt<br/><br/>S:\>move t*.txt subdir>report.txt<br/><br/>S:\>type report.txt<br/><br/>S:\test1.txt<br/>S:\test2.txt<br/>S:\test3.txt<br/>S:\test4.txt<br/>S:\test5.txt<br/> 5 file(s) moved.<br/><br/>S:\><br/><br/></body></html> | |