Here is a VBS version of the script I tested it with
C:\TestMe.txt And %Systemdrive%
It copies the file to the new location, if the file is there
then it renames it with a Back at the end of the name.
Green Text Is The Test It Can Be Removed From The Script
Red Text Is Your File Remove ' from in front of the text
Example
This Wont Work Like This
' Moz = (ApData & "Mozilla\Firefox\Profiles\8loakqo3.default\bookmarks.html")
It Must look Like This
Moz = (ApData & "Mozilla\Firefox\Profiles\8loakqo3.default\bookmarks.html")
Blue Text Is the Varible For %systemdrive% Can Be left In Or Taken out
Of the script
Save as, WHATEVER.vbs
Quote
Dim Act, ApData, Fso, Moz, NewMoz
Set Act = CreateObject("Wscript.shell")
Set Fso = CreateObject("Scripting.FileSystemObject")
ApData = Act.ExpandEnvironmentStrings("%APPDATA%")
Sd = Act.ExpandEnvironmentStrings("%Systemdrive%")
' Moz = (ApData & "Mozilla\Firefox\Profiles\8loakqo3.default\bookmarks.html")
' NewMoz = ("I:\Firefox bookmarks\script test\bookmarks.html")
Moz = ("C:\TestMe.txt")
NewMoz = (SD & "\Testme.txt")
If Fso.FileExists(Moz) Then
If Not Fso.FileExists(NewMoz) Then
Fso.CopyFile(Moz),(NewMoz)
Else
' If Fso.FileExists(NewMoz) Then
' Fso.CopyFile(Moz),("I:\Firefox bookmarks\script test\BookMarkBack.html")
If Fso.FileExists(NewMoz) Then
Fso.CopyFile(Moz),(SD & "\TestMeBack.txt")
End If
End If
Else
Act.Popup "Cannot Find This File" & vbCrLf & Moz, 5, "Error Missing", 0 + 32
End If
I added a array so it is easier to edit
Re-Edit Of The Above Code, Use The Above Color Code Part To Edit.
Place The Location In Here
MozDir = ("I:\Firefox bookmarks\script test")
Quote
Dim Act, ApData, Fso, MozDir, Moz
Set Act = CreateObject("Wscript.shell")
Set Fso = CreateObject("Scripting.FileSystemObject")
ApData = Act.ExpandEnvironmentStrings("%APPDATA%")
Sd = Act.ExpandEnvironmentStrings("%Systemdrive%")
MozDir = ("I:\Firefox bookmarks\script test")
' Moz = Array((ApData & "Mozilla\Firefox\Profiles\8loakqo3.default\bookmarks.html"),_
' (MozDir & "\bookmarksBak.html"),(MozDir & "\bookmarksBak1.html"))
Moz = Array("C:\TestMe.txt",(SD & "\Testme.txt"),(SD & "\TestmeBak.txt"))
If Fso.FileExists(Moz(0)) Then
If Not Fso.FileExists(Moz(1)) Then
Fso.CopyFile(Moz(0)),(Moz(1))
Else
If Fso.FileExists(Moz(1)) Then
Fso.CopyFile(Moz(1)),(Moz(2))
Act.Popup "File Was There And A" & vbCrLf & "New Name Was Applied" &_
vbCrLf & Moz(2), 5, "Error File There 1", 0 + 32
End If
End If
Else
Act.Popup "Cannot Find This File" & vbCrLf & Moz(0), 5, "Error Missing", 0 + 32
End If
No Rename Just Copy
Quote
Dim Act, ApData, Fso, MozDir, Moz
Set Act = CreateObject("Wscript.shell")
Set Fso = CreateObject("Scripting.FileSystemObject")
ApData = Act.ExpandEnvironmentStrings("%APPDATA%")
Sd = Act.ExpandEnvironmentStrings("%Systemdrive%")
MozDir = ("I:\Firefox bookmarks\script test")
' Moz = Array((ApData & "Mozilla\Firefox\Profiles\8loakqo3.default\bookmarks.html"),_
' (MozDir & "\bookmarksBak.html"))
Moz = Array("C:\TestMe.txt",(SD & "\Testme.txt"))
If Fso.FileExists(Moz(0)) Then
Fso.CopyFile(Moz(0)),(Moz(1))
Else
Act.Popup "Cannot Find This File" & vbCrLf & Moz(0), 5, "Error Missing", 0 + 32
End If
This post has been edited by gunsmokingman: 23 August 2005 - 11:12 PM