title: VBScript to move specified files (e.g *.txt) from a folder (and subfolder) to a specified location
body: <p>I have this script for accessing a root folder and all the subfolders of the root. The script is meant to find all the PDF files and copy them in a specified folder. Unfortunately something is not right since I get an error when trying to obtain the current folder and copy the files with <code>fso.CopyFile curDir &amp; "\*.pdf", "C:\users"</code>.</p>
  
  <pre><code>Set objFSO = CreateObject("Scripting.FileSystemObject")
  
  objStartFolder = "C:\Users\jula\Desktop\docs"
  
  Set objFolder = objFSO.GetFolder(objStartFolder)
  WScript.Echo objFolder.Path
  
  Set colFiles = objFolder.Files
  WScript.Echo "Start, I think"
  
  ShowSubfolders objFSO.GetFolder(objStartFolder)
  
  Sub ShowSubFolders(Folder)
      For Each Subfolder In Folder.SubFolders
          'displaying the current folder it's searching in
          WScript.Echo Subfolder.Path
  
          Set objFolder = objFSO.GetFolder(Subfolder.Path)
  
          Set colFiles = objFolder.Files
  
          For Each objFile In colFiles
              'obtaining the curent directory name
              curDir = objFSO.GetParentFolderName(WScript.ScriptFullName)
              objFSO.CopyFile curDir &amp; "\*.pdf", "C:\users'\jula\Desktop\folderToMoveIn"
              WScript.Echo objFile.Name
          Next
  
          WScript.Echo
  
          ShowSubFolders Subfolder
      Next
  End Sub
  </code></pre>