Skip to content

Instantly share code, notes, and snippets.

@dashmug
Created May 29, 2014 06:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dashmug/b463da29c930633333dc to your computer and use it in GitHub Desktop.
Save dashmug/b463da29c930633333dc to your computer and use it in GitHub Desktop.
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim fso, startFolder, folder, files, lines
Set fso = CreateObject("Scripting.FileSystemObject")
startFolder = fso.GetAbsolutePathName(".")
Set folder = fso.GetFolder(startFolder)
Set files = folder.Files
lines = ""
For Each file in files
If InStr(file.Name,".jpg") > 0 Then
lines = lines & "ren " & file.Name & " " & file.Name & vbCrLf
End If
Next
Set batchFile = fso.OpenTextFile(startFolder & "\rename.bat", ForWriting, True)
batchFile.Write(lines)
batchFile.Close
MsgBox "You can now check and edit " & startFolder & "\rename.bat.", vbOKOnly, "Success."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment