January 4, 2012 at 10:28 am
Hi,
I need to delete all the files from a directory named c:\sgrs except Rar files (Rar is the extension). Need to accomplish this with a DOS command.
I can do it in several steps like:
step1 ) delete all files that are in the c:\sgrs folder (txt files and others)
step2 ) delete all folders inside c:\sgrs (first have to delete all files from each folder)
This is a multi step method.
Is there any command in DOS where i can say directly to delete all that is inside c:\sgrs except .Rar files?
Thank you
Rate this post
January 4, 2012 at 10:36 am
if you're executing this within a sql server agent job i'd use a VB script
-----------------------------------------------------------------------------------------------------------
"Ya can't make an omelette without breaking just a few eggs" 😉
January 5, 2012 at 1:33 am
It's not a job. it's SQL. I need to use xp_cmdshell ( I know the security risks asociated with xp_cmdchell).
Can someone help?
January 5, 2012 at 1:36 am
Are you running this ad hoc or are you going to schedule it?
-----------------------------------------------------------------------------------------------------------
"Ya can't make an omelette without breaking just a few eggs" 😉
January 5, 2012 at 2:01 am
ad hoc
January 5, 2012 at 4:45 am
try this link. It may be what you're after......
Or, read the directory of files into a temp table, loop through that deleting the files (using xp_cmdshell) where [text] not like '%filename%'
_________________________________________________________________________________SQLGeordieWeb:- Jarrin ConsultancyBlog:- www.chrisjarrintaylor.co.ukTwitter:- @SQLGeordie
January 5, 2012 at 9:16 am
Thanks, great help (the link).
Best Regards,
PR
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply