How to List Multiple Files in a Single Folder
----------------------------------------------------------------------------------------------------------
Dim myobjFS, myobjFile, myobjFolder
Set myobjFS = Server.CreateObject("Scripting.FileSystemObject")
Set myobjFolder = myobjFS.GetFolder(Server.MapPath("/folderpath"))
For Each myFile in myobjFolder.Files
Response.Write myFile.Name & "<br>"
Next
Set myobjFolder = Nothing
Set myobjFS = Nothing
----------------------------------------------------------------------------------------------------------
How To Move Multiple Files from One Folder to another
Dim myobjFSO, myobjFolder, myFile
Dim myFolder, myTarFolder
Set myobjFSO = Server.CreateObject("Scripting.FileSystemObject")
Set myobjFolder = myobjFSO.GetFolder("D:\Sourcefolder\")
myTarFolder = "D:\Targetfolder\backup\"
For Each myFolder in myobjFolder.SubFolders
For Each myFile in myFolder.Files
if myobjFSO.FileExists(myFile)=true then
myobjFSO.CopyFile myFile,myTarFolder&myFolder.Name&"\"
'myobjFSO.MoveFile myFile,myTarFolder&myFolder.Name&"\"
myobjFSO.DeleteFile myFile
end if
Next
Next
Set myobjFolder = Nothing
Set myobjFSO = Nothing
----------------------------------------------------------------------------------------------------------
Count Files in a Folder
myFolder.Files.count (Check the above code for reference)
----------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------
Dim myobjFS, myobjFile, myobjFolder
Set myobjFS = Server.CreateObject("Scripting.FileSystemObject")
Set myobjFolder = myobjFS.GetFolder(Server.MapPath("/folderpath"))
For Each myFile in myobjFolder.Files
Response.Write myFile.Name & "<br>"
Next
Set myobjFolder = Nothing
Set myobjFS = Nothing
----------------------------------------------------------------------------------------------------------
How To Move Multiple Files from One Folder to another
Dim myobjFSO, myobjFolder, myFile
Dim myFolder, myTarFolder
Set myobjFSO = Server.CreateObject("Scripting.FileSystemObject")
Set myobjFolder = myobjFSO.GetFolder("D:\Sourcefolder\")
myTarFolder = "D:\Targetfolder\backup\"
For Each myFolder in myobjFolder.SubFolders
For Each myFile in myFolder.Files
if myobjFSO.FileExists(myFile)=true then
myobjFSO.CopyFile myFile,myTarFolder&myFolder.Name&"\"
'myobjFSO.MoveFile myFile,myTarFolder&myFolder.Name&"\"
myobjFSO.DeleteFile myFile
end if
Next
Next
Set myobjFolder = Nothing
Set myobjFSO = Nothing
----------------------------------------------------------------------------------------------------------
Count Files in a Folder
myFolder.Files.count (Check the above code for reference)
----------------------------------------------------------------------------------------------------------
No comments:
Post a Comment