Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying and deleting files with wildcards issue

Status
Not open for further replies.

ton12

Programmer
Mar 9, 2005
58
GB
Hi,

I need to copy empty files with wildcards from a
folder to another and then delete the files
from the input folder using a Stored Procedure.

Any suggestions welcome.

Regards.
Ton.
 
I'm no sql guru like most of the folks around here, so take any suggestions with a grain of salt...

Does a path to each of these files already exist inside your sql table?

What is the criteria for the files you want to copy? Everything from a specific directory, everything from a specific directory that is zero bytes?

One easy way to do it would be to use the xp_cmdshell command.

exec xp_cmdshell 'copy c:\test1\*.* c:\test3\'
exec xp_cmdshell 'del c:\test1\*.* /Q'
 
Thanks. These commands will surely do the job
but any idea how to select those files whose size is 0.

Regards.
Ton
 
Use robocopy.exe (you can get it from Microsoft). It has a max file size flag. You can simply tell it to move all files with a max size of 0 bytes and it will move all 0 byte files.

Denny
MCSA (2003) / MCDBA (SQL 2000) / MCTS (SQL 2005)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top