Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
S

Serpent666

@Serpent666
About
Posts
9
Topics
6
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Rename Extensions in subfolders
    S Serpent666

    i got it working after finding some code that monitors a folder including subfolders i just changed it around so that it checked for the extention and renamed it

    strComputer = "."
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    strFolderName=inputbox("ENTER THE FULL BACKUP PATH")
    msgbox "A messagebox will display on completion, this may take some time"

    Set colSubfolders = objWMIService.ExecQuery _
    ("Associators of {Win32_Directory.Name='" & strFolderName & "'} " _
    & "Where AssocClass = Win32_Subdirectory " _
    & "ResultRole = PartComponent")

    arrFolderPath = Split(strFolderName, "\")
    strNewPath = ""
    For i = 1 to Ubound(arrFolderPath)
    strNewPath = strNewPath & "\\" & arrFolderPath(i)
    Next
    strPath = strNewPath & "\\"

    Set colFiles = objWMIService.ExecQuery _
    ("Select * from CIM_DataFile where Path = '" & strPath & "'")

    For Each objFile in colFiles
    If objFile.Extension = "txt" Then
    strBACKUP = objFile.Drive & objFile.Path & objFile.FileName & "." & "bak"
    objFile.Copy(strBACKUP)
    End If
    Next

    For Each objFolder in colSubfolders
    GetSubFolders strFolderName
    Next

    Sub GetSubFolders(strFolderName)
    Set colSubfolders2 = objWMIService.ExecQuery _
    ("Associators of {Win32_Directory.Name='" & strFolderName & "'} " _
    & "Where AssocClass = Win32_Subdirectory " _
    & "ResultRole = PartComponent")

    For Each objFolder2 in colSubfolders2
        strFolderName = objFolder2.Name
        arrFolderPath = Split(strFolderName, "\\")
        strNewPath = ""
        For i = 1 to Ubound(arrFolderPath)
            strNewPath = strNewPath & "\\\\" & arrFolderPath(i)
        Next
        strPath = strNewPath & "\\\\"
    
        Set colFiles = objWMIService.ExecQuery \_
            ("Select \* from CIM\_DataFile where Path = '" & strPath & "'")
    
        For Each objFile in colFiles
      If objFile.Extension = "txt" Then
        strBACKUP = objFile.Drive & objFile.Path & objFile.FileName & "." & "bak"
    objFile.Copy(strBACKUP)
    End If
        Next
    
        GetSubFolders strFolderName
    Next
    

    End Sub

    thanks for the help!

    Visual Basic question tools help

  • Rename Extensions in subfolders
    S Serpent666

    Hey all, not 100% sure if this is the right forum for Visual Basic Scripting but i can only assume it is. Basicly put my current script will let you type a directory into an input box e.g C:\Temp\Files then it will rename every file in there with the extension .txt to .bak while all that works great, i have subfolders and it will not change the extensions of the txt files in them here is my current code for you to look at

    FILEPATH=inputbox("What is the directory?")

    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

    Set FileDirectory = objWMIService.ExecQuery _
    ("ASSOCIATORS OF {Win32_Directory.Name='" & FILEPATH & "'} Where " _
    & "ResultClass = CIM_DataFile")

    For Each objFile In FileDirectory
    If objFile.Extension = "txt" Then
    strbak = objFile.Drive & objFile.Path & objFile.FileName & "." & "bak"
    objFile.Copy(strbak)
    End If
    Next

    msgbox "Complete."

    im pretty sure i have to use Win32_SubDirectory.Name but i have tried to implement it and failed so can someone please help me to get my script to change subfolder file extensions?

    Visual Basic question tools help

  • Creating/Extracting Zip files via code
    S Serpent666

    thats using C# & J# i need .NET

    Visual Basic tutorial

  • Copying a listbox item to clipboard
    S Serpent666

    What code do i need to copy a selected item from a list box to clipboard so then i could paste it into any other program that accepts text

    Visual Basic

  • Creating/Extracting Zip files via code
    S Serpent666

    i need example code on how to create a zip file, add items to it, and also extracting it i wish to harness standard windows zipping, im not worried about compression it is more to do with tidyness

    Visual Basic tutorial

  • saving item to same location as the program
    S Serpent666

    i have already set up a listbox to be saved as a txt file, but now i wish to be able to have it saved to whereever the compiled program is, for example just say the program is called listboxes.exe and is in C:\testfolder then the txtfile containing the listbox data will be saved to its directory, c:\testfolder

    Visual Basic tutorial

  • multiple file copies
    S Serpent666

    already know that code, sorry but its not what im looking for im not looking for it to check for it and if its there then it will not copy im looking for code that if the file is there, it will rename it and send in the same file but rename it example: when you copy a file in windows and paste it a couple of times it will make copies like this Copy of Test Copy (2) of Test Copy (3) of Test etc etc im trying to make my program do that

    Visual Basic csharp question

  • multiple file copies
    S Serpent666

    if my vb.net form is trying to copy a file to a destination where the file already exists, how would i get it to rename the new file to something different? eg: if "C:\test.txt" exists then it will rename it to "C:\test01.txt" and if those two exist then it will rename it to "C:\test02.txt" so you could get "C:\test01.txt" "C:\test02.txt" "C:\test03.txt" "C:\test04.txt" .......... etc etc

    Visual Basic csharp question

  • Disabling Alt & Windows key
    S Serpent666

    i need help with the simplest code possible that will disable the Alt key & the Windows key cheers in advance

    Visual Basic help
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups