Move Files

L

Launa Windows

Have an Access 2003 database that includes links to html photo galleries.

Each record links to a directory that contains a series of html files - the
directory is named using a numeric field from the record - e.g. c:\80845

We need to archive some of these to save space - am looking for a way to
automatically do the following based on a status field in the record:

1) Move the files in c:\80845 to f:\80845
2) Delete the existing c:\80845 directory
3) change the hyperlink field of the record to reflect f:\80845\index.html
rather than c:

Any help appreciated

Thanks

John
 
?

=?iso-8859-1?Q?J=F6rg_Ackermann?=

Hi,

Launa Windows schreibselte:
Have an Access 2003 database that includes links to html photo
galleries.

Each record links to a directory that contains a series of html files
- the directory is named using a numeric field from the record - e.g.
c:\80845

We need to archive some of these to save space - am looking for a way
to automatically do the following based on a status field in the
record:

1) Move the files in c:\80845 to f:\80845
2) Delete the existing c:\80845 directory
3) change the hyperlink field of the record to reflect
f:\80845\index.html rather than c:


You can try in that way:

Sub ChangePath(OldPath As String, NewPath As String)

Dim sSQL As String

Const TableName = "Tabelle"
Const FieldName = "Test"

Name OldPath As NewPath

sSQL = "UPDATE " & TableName & " SET " & FieldName & "=" & _
"Replace(" & FieldName & ",'" & OldPath & "','" & NewPath & "') " & _
"WHERE " & FieldName & " Like '*" & OldPath & "*';"

CurrentDb.Execute sSQL

End Sub

Joerg
 
?

=?iso-8859-1?Q?J=F6rg_Ackermann?=

Hi,

Jörg Ackermann schreibselte:


I saw this...
Name OldPath As NewPath

Then Name... will not work, sorry

Make first:

Sub CopyFiles(OldPath As String, NewPath As String)

Call Shell("xcopy " & OldPath & "*.* " & NewPath & "*.*", vbNormalFocus)

End Sub

in imadiate window:
Call CopyFiles("c:\80845\", "f:\80845\")

then:

Sub ChangePath(OldPath As String, NewPath As String)

Dim sSQL As String

Const TableName = "Tabelle"
Const FieldName = "Test"

sSQL = "UPDATE " & TableName & " SET " & FieldName & "=" & _
"Replace(" & FieldName & ",'" & OldPath & "','" & NewPath & "') " & _
"WHERE " & FieldName & " Like '*" & OldPath & "*';"

CurrentDb.Execute sSQL

End Sub

in imadiate window:
Call ChangePath("c:\80845\", "f:\80845\")

Joerg
 
?

=?iso-8859-1?Q?J=F6rg_Ackermann?=

Hi,

Jörg Ackermann schreibselte:

a note:

I assumed your Hyperlinks are absolute.
If you have relative Hyperlinks you have to
adapt the second sub to work.

Joerg
 

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