dcsimg
Results 1 to 3 of 3

Thread: Need help in tidying up a .VBS script as extremely confused :-S

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2018
    Posts
    8

    Need help in tidying up a .VBS script as extremely confused :-S

    Hi there and apolgies if I posted in the wrong forum but Im extremely rusty on this stuff and need it idiot proof to understand. If it is in wrong one could someone move please.

    My problem:-

    I have the following scripts shown below and I believe they are too long and full of unnecessary junk and let me tell you what im trying to do.

    Im trying to create a script so that I can get it to create a folder in C:\Downloads and ask me to name the folder and then move the files that are also in C:\Downloads into the folder.
    I then need a message box or something to pop up asking if I have attached statement and if answer is "YES" I need it to carry on and if "NO" I need it to advise me with a message stating "attach the statement in folder and rerun command" and after 10 secs close the command.

    If answer is "YES" I need it to ask me to input a password for the folder and then zip the folder. I have 7zip or windows one but NOT win zip.
    Finally after the folder zipped I need it to ask me if I want to move the files to A) AAA DOWNLOADS or B) BBB DOWNLOADS and select which one.
    Once selected I need it moved to the one I advised I wanted it moved to.

    What I also need if poss when zipped I need it to keep the folder name for the zipped folder that I created the same as the one I named before zipping.

    AAA downloads to save to C:\Mydocuments\AAA DOWLOADS
    BBB downloads to save to C:\Mydocuments\BBB DOWLOADS

    The original UNZIPPED folder I always need moved to C:\Mydocuments\CCC DOWLOADS once zipped file moved into AAA or BBB downloads.

    Any help greatly appriciated. Ive got a cheek but if its only amending the text below is there any chance you could just copy and paste.

    Big Big thanks in advance
    Original script


    Option Explicit

    Const strDLFolder = "C:\Downloads"
    Dim objFSO, objWShell, objDLFolder, strNewFolder, objFile

    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objWShell = CreateObject("WScript.Shell")


    If Not objFSO.FolderExists(strDLFolder) Then objFSO.CreateFolder(strDLFolder)
    objWShell.CurrentDirectory = strDLFolder
    Set objDLFolder = objFSO.GetFolder(strDLFolder)
    If objDLFolder.Files.Count = 0 Then WScript.Quit

    Do
    Err.Clear
    strNewFolder = InputBox("Folder Name", vbLf & "Enter the name of the folder to be created:")
    If strNewFolder = False Then WScript.Quit
    On Error Resume Next
    objFSO.CreateFolder strNewFolder
    Loop While Err.Number <> 0 Or Not objFSO.FolderExists(strNewFolder)

    On Error Goto 0
    For Each objFile In objDLFolder.Files
    objFSO.MoveFile objFile.Name, strNewFolder & "\"
    Next

    objWShell.Popup "All files moved.", 0, "Done", vbInformation Or vbSystemModal Or &h00040000&

    dim dotbat
    set dotbat=createobject("wscript.shell")
    dotbat.Run "C:\Users\g\Desktop\testersnew.bat", 1, True
    set dotbat=Nothing

    @echo off&PUSHD "%PROGRAMFILES%\7-zip"&cls
    echo MAKE SURE YOU HAVE ENTERED
    echo STATEMENT INTO FOLDER BEFORE
    echo CONTINUING^^!&echo.
    echo [1] I'VE DONE THAT
    echo [2] I'VE FORGOTTEN THAT
    choice /c 12 /n>nul
    if '%errorlevel%'=='2' (
    cls&echo ENTER THE STATEMENT INTO FOLDER,
    echo THIS WINDOW WILL CLOSE IN 5 SEC.
    ) else (
    cls
    7z a -t7z "C:\Downloads\zipped.7z" "C:\Downloads"
    echo.&echo ALL FILES MOVED^^!
    )
    timeout 5 /NOBREAK >nul&exit/b

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    99,765

    Re: Need help in tidying up a .VBS script as extremely confused :-S

    If you want help with VBScript then the first step is to post in the forum dedicated to VBScript rather than the one dedicated to VB.NET. I've asked the mods to move this thread.

    Also, QUOTE tags are for quotes. As you might expect, CODE tags are for code.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2018
    Posts
    8

    Re: Need help in tidying up a .VBS script as extremely confused :-S

    I have got this script of which I believe creates a folder and then password protects it. Ive tried to code it using the # key but it not having it??

    Code:
    @echo off
    setlocal enableExtensions enableDelayedExpansion
    set "strDLFolder=C:\Downloads"
    if not exist "%strDLFolder%" md "%strDLFolder%"
    
    pushd "%strDLFolder%"
    2>nul (>nul dir /b /A:-D *) || exit /b
    
    :do
    set "strNewFolder="
    set /p "strNewFolder=Enter the name of the folder to be created: "
    if not ^"!strNewFolder:"=!" == "!strNewFolder!" goto :do
    md "%strNewFolder%" || goto :do
    
    move "*" "%strNewFolder%"
    "C:\Program Files\7zip\7z.exe" a "C:\COMPLETED\%strNewFolder%.zip" -t"zip" -m"em=ZipCrypto" "%strNewFolder%" -p
    popd
    goto :eof

    It creates the folder and that seems to be it. Can anyone assist on what im doing wrong and also does anyone have a script to add the additional items?

    I then need a message box or something to pop up asking if I have attached statement and if answer is "YES" I need it to carry on and if "NO" I need it to advise me with a message stating "attach the statement in folder and rerun command" and after 10 secs close the command.

    If answer is "YES" I need it to ask me to input a password for the folder and then zip the folder. I have 7zip or windows one but NOT win zip.
    Finally after the folder zipped I need it to ask me if I want to move the files to A) AAA DOWNLOADS or B) BBB DOWNLOADS and select which one.
    Once selected I need it moved to the one I advised I wanted it moved to.

    What I also need if poss when zipped I need it to keep the folder name for the zipped folder that I created the same as the one I named before zipping.

    AAA downloads to save to C:\Mydocuments\AAA DOWLOADS
    BBB downloads to save to C:\Mydocuments\BBB DOWLOADS

    The original UNZIPPED folder I always need moved to C:\Mydocuments\CCC DOWLOADS once zipped file moved into AAA or BBB downloads.

    Thanks
    Last edited by shreked; May 1st, 2018 at 04:23 AM. Reason: Original script posted not working

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width