Maybe someone will find this useful.
I wrote a script for my company that creates a new folder with the Windows username, a subfolder with the date, and moves the newly created PDF file into that folder. (Example: "J:\\PDFs\\Joe\\2010-04-26\\Some document.PDF")
It is useful for us because it automatically organizes all of the PDF's in one folder on a mounted network drive. PDFCreator is running locally with a copy of this script on each station, and not as a server. The username might not work the same if running in server mode.
`' MovetoUserDateFolder`
`' License: GPL`
`' Date: April 26, 2010`
`' Author: uhcafigdc`
`
`
`' This script will - `
`' Create a new folder within the specified parent folder named by the Windows environment variable %USERNAME%`
`' Create a subfolder within that folder named by the current date yyyy-mm-dd`
`' Move the newly created PDF file into that folder`
`
`
`Option Explicit`
`Const AppTitle = "PDFCreator - Move to User Date folder"`
`Dim objArgs, objShell, objFolder, objFSO, wshShell, fname, parentfolder, newfolder, username`
`
`
`' SET PARENT FOLDER HERE`
`parentfolder = "J:\\PDF\\"`
`
`
`
`
`Set objArgs = WScript.Arguments`
`
`
`If objArgs.Count = 0 Then`
` MsgBox "This script needs a parameter!", vbExclamation, AppTitle`
` WScript.Quit`
`End If`
`
`
`fname = objArgs(0)`
`
`
`
`
`' Get the username`
`Set wshShell = WScript.CreateObject("WScript.Shell")`
`username = wshShell.ExpandEnvironmentStrings("%USERNAME%")`
`
`
`' Set the new folder name`
`newfolder = username & "\\" & DatePart("yyyy",Date) & "-" & Right("0" & DatePart("m",Date), 2) & "-" & Right("0" & DatePart("d",Date), 2)`
`
`
`' Create the new folder`
`Call CreateFolder(parentfolder, newfolder)`
`Private Sub CreateFolder(pfolder, nfolder)`
` set objShell = CreateObject("Shell.Application")`
` set objFolder = objShell.NameSpace(pfolder) `
` objFolder.NewFolder nfolder`
`End Sub `
`
`
`' Move the file to the new folder`
`Call MovetoFolder(fname, parentfolder, newfolder)`
`Private Sub MovetoFolder(file, pfolder, nfolder)`
` Set objFSO = CreateObject("Scripting.FileSystemObject")`
` objFSO.MoveFile file, pfolder & nfolder & "\\"`
`End Sub`