Advertisement
SuperSilverainox

skrypt.vbs

Dec 29th, 2023
1,754
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ' Specify the source and target paths and the file format
  2. Dim sourcePath, targetPath, fileFormat
  3. sourcePath = "C:\source\path"
  4. targetPath = "D:\target\path"
  5. fileFormat = "*.png"
  6.  
  7. ' Create FileSystemObject
  8. Dim fso
  9. Set fso = CreateObject("Scripting.FileSystemObject")
  10.  
  11. ' Ensure target directory exists
  12. If Not fso.FolderExists(targetPath) Then
  13.     fso.CreateFolder(targetPath)
  14. End If
  15.  
  16. ' Function to recursively search and process files
  17. Sub ProcessFolder(folder)
  18.     Dim subFolder
  19.     For Each subFolder In folder.SubFolders
  20.         ProcessFolder subFolder
  21.     Next
  22.  
  23.     Dim file, fileName, targetFile
  24.     For Each file In folder.Files
  25.         If LCase(fso.GetExtensionName(file.Name)) = "png" Then
  26.             counter = counter + 1
  27.             fileName = counter & ".png"
  28.             targetFile = fso.BuildPath(targetPath, fileName)
  29.             file.Move targetFile
  30.         End If
  31.     Next
  32. End Sub
  33.  
  34. ' Counter for file renaming
  35. Dim counter
  36. counter = 0
  37.  
  38. ' Start processing
  39. Dim rootFolder
  40. Set rootFolder = fso.GetFolder(sourcePath)
  41. ProcessFolder rootFolder
  42.  
  43. WScript.Echo "Files transferred and renamed."
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement