1.

Solve : Batch Script Question?

Answer»

Let's say I do a simple clean up command like:

cd c:\users\username\desktop

move *.jpg c:\Images

Let's say some files were moved, is there any way to record that to a log?
Like have it look like:

Image1.jpg moved to [C:\Images]
Image2.jpg moved to [C:\Images]

You can't just echo move *.jpg C:\Images > Log.log can you?
And also, let's say it didn't move anything. Could I record that too?

All help appreciated.

 ~SacredUse the REDIRECTOR '>' '>>'
move *.jpg c:\Images >> C:\Somefile.ext

a single > will start a new file basically
a >> will append

My bad I hadn't looked at your whole structure it should be like

move "C:\Images\*.txt" 01\ >> 01\Somefile.txt
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...

Usually in a case of recording and not.. I just use a '
if exist C:\ balh BLA\*.jpg (
move......
) else (
someother command
) Quote from: pfmk2 on AUGUST 01, 2010, 09:27:03 PM

Use the redirector '>' '>>'
move *.jpg c:\Images >> C:\Somefile.ext


that will not log anything. move does not give you a stdout when it moves SUCCESSFULLY.yeah I know that.. MAYBE if ya actually read the rest.........................

well when it successfully moved on my machine it recorded just fine as
C:\Tests\01\Fri.txt
C:\Tests\01\Mon.txt
C:\Tests\01\Sat.txt
C:\Tests\01\Sun.txt
C:\Tests\01\Thu.txt
C:\Tests\01\Tue.txt
C:\Tests\01\Wed.txt
Code: [Select]
S:\>echo hello>test1.txt

S:\>echo hello>test2.txt

S:\>echo hello>test3.txt

S:\>echo hello>test4.txt

S:\>echo hello>test5.txt

S:\>move t*.txt subdir>report.txt

S:\>type report.txt

S:\test1.txt
S:\test2.txt
S:\test3.txt
S:\test4.txt
S:\test5.txt
        5 file(s) moved.

S:\>



Discussion

No Comment Found