electricwizard84
Technical User
Hi,
I am trying to create a folder based upon the base name of a filename. For example, if a file is named 'test.txt' then the program will create a folder called 'test'.
Additionally, the filename 'test.txt' shall be moved such that is become inside the folder 'test'. Also, the folder 'test' shall then be moved to a destination path.
-----------------------------------------------------
dim objFSO, objFolder, b
dim colFiles, source, destination
source = "C:\Test\"
destination = "C:\Test1\"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(source)
Set colFiles = objFolder.Files
For Each objFile In colFiles
b = objFSO.GetBaseName ("C:\Test\test.txt") 'cannot the string b store a value called 'test', from the files within a folder as opposed to having to write the extension explicitly?
objFSO.CreateFolder(b)
objFile.Move destination & "\" & objFile.Name ' I want to move the file to within the new folder.
Next
I am trying to create a folder based upon the base name of a filename. For example, if a file is named 'test.txt' then the program will create a folder called 'test'.
Additionally, the filename 'test.txt' shall be moved such that is become inside the folder 'test'. Also, the folder 'test' shall then be moved to a destination path.
-----------------------------------------------------
dim objFSO, objFolder, b
dim colFiles, source, destination
source = "C:\Test\"
destination = "C:\Test1\"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(source)
Set colFiles = objFolder.Files
For Each objFile In colFiles
b = objFSO.GetBaseName ("C:\Test\test.txt") 'cannot the string b store a value called 'test', from the files within a folder as opposed to having to write the extension explicitly?
objFSO.CreateFolder(b)
objFile.Move destination & "\" & objFile.Name ' I want to move the file to within the new folder.
Next