|
-
February 15th, 2003, 10:14 AM
#3
Hi David, you actually got me pointed in the right direction.
I'm trying this batch file:
::test.bat
@echo off
MD deltemp
for %%x in (%1 %2 %3 %4 %5 %6 %7 %8 %9) do move *.%%x deltemp
del *.*
copy deltemp\*.*
deltree /Y deltemp
If I want to delete everything except .txt and .bat files, I type:
test txt bat
This almost works, but not quite. The del *.* line prompts for confirmation and the copy deltemp\*.* works from the command line, but not in a batch!
I've obviously got the syntax for moving a file back one step in the directory wrong, but I can't seem to get this right.
(Thanks again to Vernon for showing me how to use the for . . . in command!)
Dex
EDIT: Ok, this is a bit awkward, but it solves the "confirmation on delete" problem:
::test.bat
@echo off
md deltemp1
md deltemp2
for %%x in (%1 %2 %3 %4 %5 %6 %7 %8 %9) do move *.%%x deltemp1
move *.* deltemp2
copy deltemp1\*.*
deltree /y deltemp1
deltree /y deltemp2
But I still have the problem of the copy deltemp1\*.* line, works from the command line but not in a batch!!!
EDIT 2:
Ok, this works perfectly:
::test.bat
@echo off
md c:\temp\deltemp1
md c:\temp\deltemp2
for %%x in (%1 %2 %3 %4 %5 %6 %7 %8 %9) do move *.%%x c:\temp\deltemp1
move *.* c:\temp\deltemp2
copy c:\temp\deltemp1\*.*
deltree /y c:\temp\deltemp1
deltree /y c:\temp\deltemp2
I just hate having to use explicit paths, and it just seems cumbersome and awkward. It does, however, do the job.
If I want to delete everything from the current directory except .txt and .bat files, I can just type:
test txt bat
Dex
LAST EDIT: One little bauble: the move command protests the existence of sub-directories in the directory being worked on, but it doesn't actually prevent operation. Just doesn't have a "clean" look to it.
Last edited by Dexahol; February 15th, 2003 at 11:31 AM.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|