Navigation

4/14/2014

visual basic script to create URLs from a file directory

create file with .VBS extention, and then double click to run and create the output file with the URLs.


'2014-04 Len Davidson
'
'

On Error Resume Next
Dim fso, folder, files, NewsFile,sFolder

Set fso = CreateObject("Scripting.FileSystemObject")

' this code would take argument for folder name, I hardcode it below
' sFolder = Wscript.Arguments.Item(0)
' If sFolder = "" Then
' Wscript.Echo "No Folder parameter was passed"
' Wscript.Quit
' End If

sFolder = "folder-name-here"

Set NewFile = fso.CreateTextFile(sFolder&"\FileList.txt", True)
Set folder = fso.GetFolder(sFolder)
Set files = folder.Files

For each folderIdx In files
'  only want to include PDF files
If InStr(folderIdx.Name, ".pdf") > 0 Then
NewFile.WriteLine("http://your-server.com/mockup/test1/uploading/" & sFolder & "/" & folderIdx.Name)
end if
Next
NewFile.Close



Source

No comments:

Post a Comment