Making a "batch" or "vbscript" do this...

DocDoo

Golden Member
Oct 15, 2000
1,188
0
0
Currently I've been running a fairly basic (command) batch file that copies files named *.log from drive E: to drive F:\destination then delete all files (*.*) on drive E:.

Now I need a different batch script because of software changes.

Q: What I need the new script to do?

A: Copy only *.log and *.ghm from drive E:\unknown\folders\ to F:\destination then delete everything (files & folder\subfolder) on drive E:

The tricky part is, the folders & subfolders on source (E) are always different and never named the same, so the location of the 2 files (*.log & *.ghm) are not always known (except that they are within drive E).

A bonus would be to be able ignore same named files (source/destination).

This can be in .BAT or .VBS format. (BAT would be cleaner for me and allow me to recompile it)

-Thanks
 

DocDoo

Golden Member
Oct 15, 2000
1,188
0
0
Well, answering my own questions again ;)

I decided to use the XXCOPY command with some clever switches. The end result is very clean and easily recompiled.

ps. If someone finds a different way to do this outside of DOS, chime in.

 

skace

Lifer
Jan 23, 2001
14,488
7
81
I was going to offer the following but it looks like you already figured it out. I didn't bother testing this because theres really no point now, but here it is for reference anyways =p

I needed to test rmdir on a partition root level but don't have a good test subject. So bleh! No clue what xxcopy is.

...wow... attach code butchers end line "\"'s
 

DocDoo

Golden Member
Oct 15, 2000
1,188
0
0
Hey skace,

I ran the script and it works fine right out of the box!

I ended up going with XXCOPY because of the many available advanced switches. (you should look into this)

I'm not entirely sure what "%~2"==" does but I assume its "if file matches.."

I also like the use of the %variable and never thought of it.

I must say, I haven't played with batch commands in years so I'm very rusty...but they sure can do just about anything.

ECHO Thanks for all your effort ;)
 

skace

Lifer
Jan 23, 2001
14,488
7
81
Hehe cool :). "%~2" is the same as "%2" except the tilde (~) tells it to remove any spaces in the variable. This is good practice because dos is dumb and if your if theres multiple quotes in your if statement, it will break. Have fun!