electricwizard84
Technical User
Dear all,
This thread is related to another thread i have just posted (For Each command skipping over some files), but refers to a different problem. For convenience, i have created two separate scripts with the aim of embedding elements of this script below to the main script in the first thread.
I am trying to write a script that renames only the first 9 files within a directory to a particular syntax. For example, the idea is that the first 9 video files are renamed to something such as 'Game of Thrones - S01E0X.mkv' where X is incremented up to 9. My first script actually already performs this but i needed to change 'E' (S01E10) to 'E0' (E01E09) for the first 9 files.
I have dabbled with while loops, and .Count statements to count the first 9 files, but there is an issue with embedded this loop within the For Each loop.
Any support would be much appreciated.
-----------------
Dim sName, source, c, Name, Season, Episode, i
Dim fso
Dim fol
' create the filesystem object
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
' find location of files
source1 = InputBox("Enter video source path:")
source = source1 & "\"
Set fol = fso.GetFolder(source)
'--------------------------------------------------
i = 0
For Each fil In fol.Files
'Do While i<9
fil.name = Replace(fil.Name, "good", "test")
'i = i+1
'loop
next
'--------------------------------------------------
WScript.Echo "Completed!
This thread is related to another thread i have just posted (For Each command skipping over some files), but refers to a different problem. For convenience, i have created two separate scripts with the aim of embedding elements of this script below to the main script in the first thread.
I am trying to write a script that renames only the first 9 files within a directory to a particular syntax. For example, the idea is that the first 9 video files are renamed to something such as 'Game of Thrones - S01E0X.mkv' where X is incremented up to 9. My first script actually already performs this but i needed to change 'E' (S01E10) to 'E0' (E01E09) for the first 9 files.
I have dabbled with while loops, and .Count statements to count the first 9 files, but there is an issue with embedded this loop within the For Each loop.
Any support would be much appreciated.
-----------------
Dim sName, source, c, Name, Season, Episode, i
Dim fso
Dim fol
' create the filesystem object
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
' find location of files
source1 = InputBox("Enter video source path:")
source = source1 & "\"
Set fol = fso.GetFolder(source)
'--------------------------------------------------
i = 0
For Each fil In fol.Files
'Do While i<9
fil.name = Replace(fil.Name, "good", "test")
'i = i+1
'loop
next
'--------------------------------------------------
WScript.Echo "Completed!