Lotusscript to rename downloaded files

Duffbert and Jim Casale bothblogged 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).

Belowis my Lotusscript code. Note that I have not been able to test the actual renaming part, since I am atthe officeand 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 Ijust 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 StringDim dirname As StringDim filename As StringDim filecode As StringDim filedescription As StringDim temp As StringDim newitem As IntegerDim fromfile As StringDim tofile As Stringdlmgrfile = "c:dlmgr.pro" Open dlmgrfile For Input As #1Do 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 IfLoopClose #1
This LotusScript was converted to HTML using the ls2html routine,
provided by Julian Robichaux at nsftools.com.

 

Leave a Reply