Moving and Deleting Files

C

Chris W

how do I move files from a folder to another folder, and
then the other thing is how do I delete the files after
they have been moved, of course I only want to delete the
files that arte older than 7 days. Here is some script,
but for some reason it is not doing what I need it to do.
It does nothing: I have included the scripts in text
below, didn't know if anyone could possibly point me in
the correct direction:



Move Files:



Const FOF_CREATEPROGRESSDLG = &H0&

TargetFolder = "C:\Move"

Set objShell = CreateObject("Shell.Application")

Set objFolder = objShell.NameSpace(TargetFolder)

objFolder.MoveHere "C:\logfiles", FOF_CREATEPROGRESSDLG



Delete files: (Yes I know I have to add a way to check if
they are older than 7 days, but I was just testing to make
sure it worked before I added that in there, and so far
nothing)



Const DeleteReadOnly = True

Set objFSO = CreateObject("Scripting.FileSystemObject")

objFSO.DeleteFile("C:\logfiles\*.log"), DeleteReadOnly

..
 
R

Ray at

Please don't multi-post. There's an answer waiting in one of the other
groups you posted this message to.

Ray at work
 
C

Chris W

Sorry about that, but apparently it changed places on me,
cause when I went to refresh after a few minutes it did
not appear. My fault, I apologize.
 
P

Phil Robyn

Chris said:
how do I move files from a folder to another folder, and
then the other thing is how do I delete the files after
they have been moved, of course I only want to delete the
files that arte older than 7 days. Here is some script,
but for some reason it is not doing what I need it to do.
It does nothing: I have included the scripts in text
below, didn't know if anyone could possibly point me in
the correct direction:



Move Files:

move c:\somefolder\*.txt d:\someotherfolder
Const FOF_CREATEPROGRESSDLG = &H0&

TargetFolder = "C:\Move"

Set objShell = CreateObject("Shell.Application")

Set objFolder = objShell.NameSpace(TargetFolder)

objFolder.MoveHere "C:\logfiles", FOF_CREATEPROGRESSDLG



Delete files: (Yes I know I have to add a way to check if
they are older than 7 days, but I was just testing to make
sure it worked before I added that in there, and so far
nothing)

forfiles -pc:\cmd -s -m*.* -d-8 -c"cmd /c if NOT @ISDIR==TRUE echo del 0x22@PATH\@FILE0x22"

(If this appears to do what you intend, remove the word 'echo' from the preceding.)

You can download FORFILES.EXE for free from Microsoft at

ftp://ftp.microsoft.com/ResKit/y2kfix/x86/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top