gpt4 book ai didi

用于排序 URL 的 Windows 批处理文件脚本

转载 作者:可可西里 更新时间:2023-11-01 10:01:26 26 4
gpt4 key购买 nike

如何编写 Windows 批处理脚本,通过将具有唯一文件名的 URL 分组到文本文件中来对 URL 进行排序?我不知道如何进一步描述我想要实现的目标,但我希望下面的例子能解释一切:

我想要这段文字

http://example.com/5235/Guava.jpg
http://example.com/2725/Guava.jpg
http://example.com/4627/Guava.jpg
http://example.com/8385/Guava.jpg
http://example.com/3886/Lemon.jpg
http://example.com/5896/Lemon.jpg
http://example.com/2788/Lemon.jpg
http://example.com/1758/Lemon.jpg
http://example.com/1788/Apple.jpg
http://example.com/1567/Apple.jpg
http://example.com/8065/Apple.jpg
http://example.com/6467/Apple.jpg
http://example.com/1464/Banana.jpg
http://example.com/6581/Banana.jpg
http://example.com/4642/Banana.jpg
http://example.com/8635/Banana.jpg
http://example.com/2578/Pineapple.jpg
http://example.com/1452/Pineapple.jpg
http://example.com/8652/Pineapple.jpg
http://example.com/9463/Pineapple.jpg
http://example.com/9765/Peach.jpg
http://example.com/3578/Peach.jpg
http://example.com/3583/Peach.jpg
http://example.com/9467/Peach.jpg
http://example.com/3683/Mango.jpg
http://example.com/3479/Mango.jpg
http://example.com/1795/Mango.jpg
http://example.com/7345/Mango.jpg

这样排序

http://example.com/5235/Guava.jpg
http://example.com/3886/Lemon.jpg
http://example.com/1788/Apple.jpg
http://example.com/1464/Banana.jpg
http://example.com/2578/Pineapple.jpg
http://example.com/9765/Peach.jpg
http://example.com/3683/Mango.jpg
http://example.com/2725/Guava.jpg
http://example.com/5896/Lemon.jpg
http://example.com/1567/Apple.jpg
http://example.com/6581/Banana.jpg
http://example.com/1452/Pineapple.jpg
http://example.com/3578/Peach.jpg
http://example.com/3479/Mango.jpg
http://example.com/4627/Guava.jpg
http://example.com/2788/Lemon.jpg
http://example.com/8065/Apple.jpg
http://example.com/4642/Banana.jpg
http://example.com/8652/Pineapple.jpg
http://example.com/3583/Peach.jpg
http://example.com/1795/Mango.jpg
http://example.com/8385/Guava.jpg
http://example.com/1758/Lemon.jpg
http://example.com/6467/Apple.jpg
http://example.com/8635/Banana.jpg
http://example.com/9463/Pineapple.jpg
http://example.com/9467/Peach.jpg
http://example.com/7345/Mango.jpg

换句话说,对于这个特定的例子(每个水果 jpeg 有四个)我想根据这种方式对行进行排序:1, 5, 9, 13, 17, 21, 25, 2, 6, 10, 14 、18、22、26 等等。我希望你明白我的意思。

文本文件总是包含具有相同编号的每个“水果”图片的 url。不能有六个柠檬 jpg 文件和四个 Guava jpg 文件。我希望你明白我的意思。

最佳答案

也许是这样的:

@ECHO OFF
SET origfile=urls.txt
SET c=1
SET skip=4
FOR /L %%c IN (1,1,%skip%) DO IF EXIST %origfile%.%%c DEL %origfile%.%%c
FOR /F "tokens=*" %%L IN (%origfile%) DO CALL :process "%%L"
DEL %origfile%
FOR /L %%c IN (1,1,%skip%) DO (
TYPE %origfile%.%%c >> %origfile%
DEL %origfile%.%%c
)
GOTO :EOF

:process
ECHO %~1>>%origfile%.%c%
SET /A c=c%%skip+1

想法是将后续行输出到不同的文件,每 4 行重复一次序列(实际上这里参数化了 4,因此您可以轻松更改它),然后将这些文件连接到原始名称下。

关于用于排序 URL 的 Windows 批处理文件脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5520396/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com