Link to home
Start Free TrialLog in
Avatar of shaz0503
shaz0503

asked on

How can I move files from one location to another.

All

How can I move files from one location to another.

I currently have files that are produced every month and 'sent' to specific folders.  I would like to be able to then move these to another folder at the end of the month so that only the current month reports are available in the original folder

Example
Before new reports are 'sent' to the below folder

S:\Statement of Expectations\General Staff\Finance Office

I would like all files within the folder moved to

S:\Statement of Expectations\General Staff\Finance Office\old

Is this possible and if so can I do from a button or even on opening of the database.

TIA

shaz
ASKER CERTIFIED SOLUTION
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of shaz0503
shaz0503

ASKER

Thanks

I have used your suggestion must be doing something wrong.

Below is what I am using - is this correct

Private Sub Command16_Click()
Dim sFiles As String

sFiles = Dir("S:\Statement of Expectations\General Staff\Finance Office\*.*")

Do Until sFiles = ""
  FileCopy "S:\Statement of Expectations\General Staff\Finance Office", "S:\Statement of Expectations\General Staff\Finance Office\Old"
  sFiles = Dir
Loop


End Sub

thx
S
you did not include the file

sFiles = Dir("S:\Statement of Expectations\General Staff\Finance Office\*.*")

Do while sFiles <> ""
  FileCopy "S:\Statement of Expectations\General Staff\Finance Office\" & sFiles, "S:\Statement of Expectations\General Staff\Finance Office\Old\" & sFiles
  sFiles = Dir
Loop

Thanks

Works a treat but I neglected to mention in the first instance that I need to cut/remove these files and paste to new directory.

tia

s
sFiles = Dir("S:\Statement of Expectations\General Staff\Finance Office\*.*")

Do while sFiles <> ""
  FileCopy "S:\Statement of Expectations\General Staff\Finance Office\" & sFiles, "S:\Statement of Expectations\General Staff\Finance Office\Old\" & sFiles

  'check if the file was copied
 if dir("S:\Statement of Expectations\General Staff\Finance Office\Old\" & sFiles) <> "" then
      'delete the file from the original folder
         kill "S:\Statement of Expectations\General Staff\Finance Office\" & sFiles
 end if

  sFiles = Dir
Loop
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks both -
Have been on leave and neglected to answer sooner,,,

This turns out to be a bigger than is worth..

Will continue to do the old way....

rgds