[in .vbs][3in1] Create multiple folder 180 => Create subfolders in All 180 => Move file and rename file in Subfolders created [3in1] “x, y, z”

纵然是瞬间 提交于 2019-12-11 01:26:32

问题


"x, y, z" (vertical, horizontal, Move and rename files.) i want to combine 3in1 (x,y,z.).vbs

in .vbs [summary]

Read it first here

"x" Trying to create multiple folders with VBScript

Option Explicit
Dim objFSO, objFolder, strDirectory, i
strDirectory = "C:\New folder (2)\"

Set objFSO = CreateObject("Scripting.FileSystemObject")
i = 0
While i < 180
Set objFolder = objFSO.CreateFolder(strDirectory & i)
i = i+1
WScript.Quit
Wend

"y" Help To create Folder1/Folder2 in Windows using VBScript ( Both the folders not exists before, i mean to create multilevel folders @ a strech.)

Set objShell = CreateObject("Wscript.Shell")
objShell.Run "cmd /c mkdir C:\folder1\folder2\folder3"

or

Set fs = CreateObject("Scripting.FileSystemObject")
fs.CreateFolder("C:\New folder\Client")
fs.CreateFolder("C:\New folder\Client\subclient")
fs.CreateFolder("C:\New folder\Client\subclient\subsubclient")

"z"

Set x = CreateObject("Scripting.FileSystemObject")
x.MoveFile "C:\myfile.txt" , "C:\New folder\myfile222.txt"

i want make

I hope you understand where I'm going with "x, y, z" (vertical, horizontal, Move and rename files.)

"x" Create multiple folders (i = 0 | i < 180 folders)

"y" subfolders (in All "x" 180 folders)

"z" and Move file and rename in new location

myFSO.MoveFile "C:\myfile1.txt" , "C:\New folder\myfile222.txt"

for 180 send to each 180 "x,y"...subfolders


1) Create multiple folder like script up 0-180 folders

2) Create subfolders in All 180 Folders created.

3) Move file (C:\Name.txt) and rename file in subfolder (C:\New folder\FolderB\Folder1\FolderQ\folder3\folderG\myfile222.txt)

C:\New folder\FolderB\Folder1\FolderQ\folder3\folderG

I want to combine all in one script.


I need [create multiple folder] [and every folder created 180] = >> [I want to create subfolders] [And move file (name.txt) and rename in subfolder]

ex: folder i < 180 , in every folder 1-180 created I want to create subfolders, in all 180 folders

"x" Create multiple folders like (i = 0 | i < 180 folders)

"y" Subfolders like

"C:\New folder\FolderB\Folder1\FolderQ\folder3\folderG

"z" Move file and Rename file in Subfolders like

myFSO.MoveFile "C:\myfile1.txt" , "C:\New folder\myfile222.txt"

myFSO.MoveFile "C:\myfile1.txt" , "C:\New folder\FolderB\Folder1\FolderQ\folder3\folderG\myfile222.txt"

I want to combine multiple folders with subfolders in each folder 180, And move file (Name.txt) and rename file in subfolder (FolderG)

Thank you for you help. Please excuse my English I have translated in Google Translate I hope you understand where I'm going with "x, y, z" (vertical, horizontal, files.)


回答1:


Dim i

With CreateObject("Scripting.FileSystemObject")
    For i = 0 to 179
        SmartCreateFolder "C:\Test\MySet\Folder" & i
        .CopyFile "C:\Test\data.txt", "C:\Test\MySet\Folder" & i & "\file_" & Left(CreateObject("Scriptlet.TypeLib").GUID, 38) & ".txt", True
    Next
    .DeleteFile "C:\Test\data.txt", True
End With

Sub SmartCreateFolder(strFolder)
    ' http://www.visualbasicscript.com/tm.aspx?m=29290
    With CreateObject("Scripting.FileSystemObject")
        If Not .FolderExists(strFolder) then
            SmartCreateFolder(.getparentfoldername(strFolder))
            .CreateFolder(strFolder)
        End If
    End With 
End Sub

Thanks for SmartCreateFolder 2 @EBGreen



来源:https://stackoverflow.com/questions/23150146/in-vbs3in1-create-multiple-folder-180-create-subfolders-in-all-180-mo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!