将批处理(.bat)脚本转换为bash或python

时间:2018-09-09 14:14:55

标签: python bash batch-file

所以我有以下批处理脚本,需要将其转换为bash或python,最好是python。但是因为我知道bash,所以我想先将其转换为bash,然后再将bash转换为python。

@echo off
REM Version ${project.version}

set DESTINATION_PATH=C:\Events\
set TEMP_EXTENSION=.tmp
set FINAL_EXTENSION=.txt

for /f "delims=:. tokens=1-4" %%t in ("%TIME: =0%") do (
        set FILENAME=event-%5-%%t%%u%%v%%w
    )

echo cycleNumber = %1 >> %DESTINATION_PATH%%FILENAME%%TEMP_EXTENSION%
echo runFolder = %2 >> %DESTINATION_PATH%%FILENAME%%TEMP_EXTENSION%
echo netFolder = %3 >> %DESTINATION_PATH%%FILENAME%%TEMP_EXTENSION%
echo runType = %4 >> %DESTINATION_PATH%%FILENAME%%TEMP_EXTENSION%
echo eventType = %5 >> %DESTINATION_PATH%%FILENAME%%TEMP_EXTENSION%
echo softwareType = HCS >> %DESTINATION_PATH%%FILENAME%%TEMP_EXTENSION%

rename %DESTINATION_PATH%%FILENAME%%TEMP_EXTENSION% %FILENAME%%FINAL_EXTENSION%

exit 0

这是我到目前为止所拥有的:

#@echo off
set -v
#REM Version ${project.version}
# ${project.version}

#set DESTINATION_PATH=C:\Events\
#set TEMP_EXTENSION=.tmp
#set FINAL_EXTENSION=.txt

export DESTINATION_PATH=/blah/Events
export TEMP_EXTENSION=".tmp"
export FINAL_EXTENSION=".txt"

我使用此网站来帮助我弄清楚bash中的等效符号是什么:

http://tldp.org/LDP/abs/html/dosbatch.html

现在,我陷入了困境,不知道如何解释for循环或.bat脚本的其余部分。我目前还不确定我的解释是正确的。请指教。

0 个答案:

没有答案