Skip to content Skip to sidebar Skip to footer

Get A Variable As Filename From Python Script And Use It In A Batch Script

I have a python script which gives the output as: The lastest filename of a directory. I want to use this filename in a batch script. How can i able to do it?

Solution 1:

You can get the output of a command with a for /f loop:

for /f "delims=" %%a in ('command') doset"var=%%a"

replace command with your phyton script.

Note: as written, the variable will contain the last line (or only one) of the output.

Note: this is batch file syntax. If you use it directly on command line, replace every %%a with %a

Post a Comment for "Get A Variable As Filename From Python Script And Use It In A Batch Script"