Write a VBS, want to add a folder below all subfolders documents suffixes all out to arrange, but always said strange file already exists The code below
The Function FilesTree (sPath) 'through a folder all folders folder The Set oFso=CreateObject (" Scripting. FileSystemObject ") The Set oFolder=oFso. GetFolder (sPath) The Set oSubFolders=oFolder. SubFolders
SMoveToPath=oFolder. ParentFolder. Path SAddName=oFolder. Name SAddName="-" & amp; sAddName & amp; "] " If oSubFolders. Count> 0 then For Each oSubFolder oSubFolders In Recursive FilesTree (oSubFolder) ' If oSubFolder. Size<50 then OSubFolder. Delete End the if Next End the if
The Set oFiles=oFolder. Files For Each oFile oFiles In SNewName=ofile. Name SNewName=mid (sNewName, 1, instrrev (sNewName, ". ") - 1) & amp; SAddName & amp; Mid (sNewName, instrrev (sNewName, "")) Ofile. Name=sNewName 'is the problem here is 'msgbox sMoveToPath& "\ n" & amp; Ofile. Path 'look from msgbox does not exist the nuptial OFso, movefile ofile path, sMoveToPath 'not in the mobile 'ofile. Move (sMoveToPath) Next The Set oFolder=Nothing
The Set oFso=Nothing End the Function
The set oSubFolders=CreateObject (" Scripting. FileSystemObject "). GetFolder (". "). SubFolders For Each oSubFolder oSubFolders In FilesTree (oSubFolder. Path) 'recursive Next The Set oSubFolders=Nothing
Due to the large file Numbers (5000 +), large size (about 1 gb), in order to guarantee the speed may not be able to use the Copy + Delete For help, thank humbly
CodePudding user response:
Baidu had also didn't find the right solution, tell me what kind of keyword search also line
CodePudding user response:
Your sMoveToPath variable values are not correct!
If sMoveToPath represents a "directory", its value in oFso, movefile ofile. The path, sMoveToPath here, must end with "", But before I see you in the face of the assignment is only this: sMoveToPath=oFolder. ParentFolder. Path Should be changed to: sMoveToPath=oFolder. ParentFolder. Path & amp; ""