使用批处理文件从URL复制文本

时间:2018-02-19 05:52:07

标签: batch-file

我想知道是否还有将原始pastebin页面的内容复制到批处理中:

example :
https://pastebin.com/raw/J5xb0eUX

然后使用echo命令显示它

1 个答案:

答案 0 :(得分:1)

您应该在临时文件夹中下载原始代码,然后使用命令Type编辑它,如下代码:

@echo off
Title Download code from pastebin and display it with batch
Set "url=https://pastebin.com/raw/J5xb0eUX"
for %%# in (%url%) do ( set "File=%tmp%\%%~n#.txt" )
Call :Download "%url%" "%File%"
If exist "%File%" Type "%File%"
Pause>nul & Exit
::*********************************************************************************
:Download <url> <File>
Powershell.exe -command "(New-Object System.Net.WebClient).DownloadFile('%1','%2')"
exit /b
::*********************************************************************************

编辑:

这是显示代码并将其保存在新文本文件中的另一个示例:

@echo off
Title Download code from pastebin and display it with batch
Set "url=https://pastebin.com/raw/vzx1dEdW"
for %%# in (%url%) do ( set "File=%tmp%\%%~n#.txt" )
Call :Download "%url%" "%File%"
If exist "%File%" ( 
    ( Type "%File%")>con
Rem to save the contents in new text file
( Type "%File%" > Multi_Downloading_Files.txt)
)
Start "" Multi_Downloading_Files.txt
Pause>nul & Exit
::*********************************************************************************
:Download <url> <File>
Powershell.exe -command "(New-Object System.Net.WebClient).DownloadFile('%1','%2')"
exit /b
::*********************************************************************************