Windows command line to python


Joined
Sep 29, 2021
Messages
1
Reaction score
0
I learn best from doing. So I am attempting to convert some batch files to python in order to get a feel. I dabble lightly in coding, so it's fair to say I can tell my brown eye from SOME holes in the ground, barely. I am looking at "set" and the "/p" switch (as well as calling the variables with %%) and I can't understand it. Don't worry, you don't have to write my code for me, it would be appreciated though, the minimum I am hoping for is the barney style explanation my brain needs sometimes to connect the dots. Below is a sample of my batch that I am having trouble converting.

Code:
:FUNCTION


    SET /p DE= File name (e.g. Filename.Png)?&CLS
    
    SET /p DA=Data file name (e.g. Filename.Png)?&CLS
    
    SET /p GH=Output file name without extension (e.g. .Zip, .Jpg, .M4A)?&CLS
    
    SET /p EX=Output file extension (e.g. .Zip, .Jpg, .M4A)?&CLS




    IF EXIST "%D%" IF EXIST "%DA%" (
    
        echo Files Found!
        
        COPY /b "%D%" + "%DA%" %GH%%EX% > nul
        
        GOTO CONTINUE
        
        )
        
    ) ELSE (
    
        echo Cannot Find Files, check names, extensions, and location.
        
        GOTO ERROR
        
    )


    :CONTINUE
    
        ECHO %GH%%EX% Success.
        
        GOTO timer
        
        exit /b 0


    :ERROR
    
        ECHO %GH%%EX% Failed.
        
        GOTO TIMER
        
        exit /b 0


    :TIMER
    
        TIMEOUT /T 3 > nul
        
        exit /b 0
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top