Lotusscript to rename downloaded files
Duffbert and Jim Casale both blogged about the cryptic names on downloaded files from the IBM Passport Advantage site. Jim's Excel macro inspired me to write something in Lotusscript (I don't even have Excel on my home computers anymore, I am only using Symphony now).
Below is my Lotusscript code. Note that I have not been able to test the actual renaming part, since I am at the office and I have all the files downloaded at home. But the parsing part works. You may want to either modify the location of dlmgr.pro, or even write some code to let the user select the file to process. But I just made a quick-and-dirty hack for now.
Update: Something went wrong earlier when I tried to post this, I got two borked entries. It seems like if I paste certain formatted text (like the code section below) into the entry, and save it while in preview/WYSIWYG mode, it breaks the entry. If I am in HTML code view, it works... Update 2: Thanks to the guys at Lotus911, they removed the two bad entries. Also, I wanted to clarify, the code is actually copying the files and giving the copy a new name, the original files are still there. If you want to perform a move, un-comment the the line Kill fromfile.
Dim dlmgrfile As String
Dim dirname As String
Dim filename As String
Dim filecode As String
Dim filedescription As String
Dim temp As String
Dim newitem As Integer
Dim fromfile As String
Dim tofile As String
dlmgrfile = "c:\dlmgr.pro"
Open dlmgrfile For Input As #1
Do While Not Eof(1)
Line Input #1, temp
If Left$(temp,6)=".file=" Then
filecode = Right$(temp,Len(temp)-6)
newitem = True
Elseif Left$(temp,2) = ".." Then
newitem = False
End If
If Left$(temp,7) = "..path=" Then
dirname = Right$(temp,Len(temp)-7)
End If
If Left$(temp,8)="..title=" Then
filedescription = Right$(temp,Len(temp)-8)
End If
If Left$(temp,7)="..name=" Then
filename = Right$(temp,Len(temp)-7)
End If
If newitem = False Then
If filename<>"" Then
If dirname<>"" Then
If filedescription<>"" Then
fromfile = dirname & "\" & filename
tofile = dirname & "\" & filedescription & Right$(filename,4)
Print "Copying " & fromfile & " to " & tofile
Filecopy fromfile, tofile
' Kill fromfile
dirname = ""
filename = ""
filedescription = ""
filecode = ""
End If
End If
End If
End If
Loop
Close #1
This LotusScript was converted to HTML using the ls2html routine, provided by Julian Robichaux at nsftools.com.
|
Ratings
0
|
Comments (1)
Cool beans. This works too :-)