AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

    • 主页
    • 系统&网络
    • Ubuntu
    • Unix
    • DBA
    • Computer
    • Coding
    • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-820355

Bricktop's questions

Martin Hope
Bricktop
Asked: 2024-03-13 07:08:38 +0800 CST

有什么方法可以仅在硬盘空闲时执行批处理文件移动操作吗?

  • 6

我知道如何检查特定程序是否正在运行,winrar这可能表明驱动器上的使用情况d:,但有没有更好的方法来确定驱动器是否相对空闲(通过Batch或其他方法,从 a 调用Batch file)以开始移动大文件(在后台运行的批处理文件中),因为同时移动操作似乎会削弱我的计算机,我猜可能是由于 100% HDD 使用率。对驱动器进行碎片整理但仍然如此。

windows
  • 1 个回答
  • 53 Views
Martin Hope
Bricktop
Asked: 2024-02-25 20:50:29 +0800 CST

如何跳过 FOR 循环中的一个循环?

  • 8

我正在运行批处理脚本来处理一些文件。当它确定当前文件不需要处理时,我想跳过该文件的其余命令并直接移至下一个。如何?Goto :EOF并且exit /b都退出整个脚本。

这是脚本。它需要一个目录并重命名所有文件以包含父目录名称中的所有单词(文件名中已包含的单词除外)。

@echo off
setlocal enabledelayedexpansion

rem set input directory (add check for validity)
set "inputDir=%~1"
set "confirmation=false"

:proceed
for /r "%inputDir%" %%F in (*.*) do (
    rem use path to file as keywords
    set "words=%%~pF"
    rem replace known useless marks with spaces
    set "words=!words:\= !"
    set "words=!words:_= !"
    set "words=!words:,= !"
    set "words=!words:  = !"
    rem remove known useless words
    set "words=!words: The = !"
    set "words=!words: A = !"
    set "words=!words: An = !"
    set "words=!words: Video = !"
    set "words=!words: New Folder = !"
    rem remove word that already exists in the filename
    for %%W in (!words!) do echo %%~nF | find /i "%%W" >nul && set "words=!words: %%W = !"
    rem replace leading and trailing spaces with brackets
    set "words=[!words:~1,-1!]"
    rem if all words already included end task for current file
    if "!words!"=="[]" exit /b
    rem build the new filename
    set "newName=%%~nF !words!%%~xF"
    rem fix "] [" caused by repeated renaming, causes fusion with non-related bracketed sets, which is fine
    set "newName=!newName:] [= !"
    rem task for displaying the name change for confirmation
    if /i not "%confirmation%"=="yes" echo old "%%F" && echo new "!newName!"
    rem task for doing the actual rename if confirmed
     if /i "%confirmation%"=="yes" echo ren "%%~nxF" "!newName!" & echo ren "%%F" "!newName!"
)

rem fails to rename files with ! mark in the filename. no other trouble, just won't rename those. error: the syntax of the command is incorrect

rem if coming from second (completed) run then exit
if /i "%confirmation%"=="yes" exit /b
rem ask for confirmation to run again for real
set /p confirmation="confirm you want to perform all these rename tasks (type yes or no)?: "
if /i not "%confirmation%"=="yes" echo confirmation denied
if /i "%confirmation%"=="yes" goto proceed

endlocal

我也在尝试一种有条件地运行最后命令的替代方法,如下所示

@echo off
setlocal enabledelayedexpansion

rem set input directory (add check for validity)
set "inputDir=%~1"
set "confirmation=false"

:proceed
for /r "%inputDir%" %%F in (*.*) do (
    rem use path to file as keywords
    set "words=%%~pF"
    rem replace known useless marks with spaces
    set "words=!words:\= !"
    set "words=!words:_= !"
    set "words=!words:,= !"
    set "words=!words:  = !"
    rem remove known useless words
    set "words=!words: The = !"
    set "words=!words: A = !"
    set "words=!words: An = !"
    set "words=!words: Video = !"
    set "words=!words: New Folder = !"
    rem remove word that already exists in the filename
    for %%W in (!words!) do echo %%~nF | find /i "%%W" >nul && set "words=!words: %%W = !"
    rem replace leading and trailing spaces with brackets
    set "words=[!words:~1,-1!]"
    rem if all words not already included in the filename do
    if not "!words!"=="[]" (
        rem build the new filename
        set "newName=%%~nF !words!%%~xF"
        rem fix "] [" caused by repeated renaming, causes fusion with non-related bracketed sets, which is fine
        set "newName=!newName:] [= !"
        rem task for displaying the name change for confirmation
        if /i not "%confirmation%"=="yes" echo old "%%F" && echo new "!newName!"
        rem task for doing the actual rename if confirmed
        if /i "%confirmation%"=="yes" echo ren "%%~nxF" "!newName!" & echo ren "%%F" "!newName!"
    )
)

rem fails to rename files with ! mark in the filename. no other trouble, just won't rename those. error: the syntax of the command is incorrect

rem if coming from second (completed) run then exit
if /i "%confirmation%"=="yes" exit /b
rem ask for confirmation to run again for real
set /p confirmation="confirm you want to perform all these rename tasks (type yes or no)?: "
if /i not "%confirmation%"=="yes" echo confirmation denied
if /i "%confirmation%"=="yes" goto proceed

endlocal

但这是一场灾难,导致文件名被从文件名中看似随机的部分中删除并words添加了。

windows
  • 2 个回答
  • 1395 Views
Martin Hope
Bricktop
Asked: 2021-09-07 23:45:33 +0800 CST

无法使用 ffprobe 提取持续时间信息,文件名中的逗号弄乱了我的 for 循环

  • 7

这个批处理脚本从%folder%using创建一个文件列表%wildcards%,然后在驱动器上创建一个镜像目录,其中包含c:每个文件的 txt 版本every file.mkv.txt,其中包含原始文件的数据,如path-to-file/duration/size.

setLocal enableDelayedExpansion
:: adder fails with filenames with ampersand "&". investigate
for /f "delims=" %%v in ('dir "%folder%\%wildcards%" /b /s /a-d 2^>nul') do (
    if not exist "c:%%~pv" mkdir "c:%%~pv"
    if not exist "c:%%~pnxv.txt" for /f "usebackq tokens=2 delims=," %%i in ('"%ffprobe%" -v quiet -show_entries "format=duration" -of csv "%%v"') do (
        rem record path-to-file/duration/size into mirror files
        echo %%v/%%i/%%~zv>"c:%%~pnxv.txt"
    )
)

在某些文件上成功而在其他文件上失败,我认为它与执行到文件,的部分中的逗号有关。看起来我需要使用逗号作为分隔符,因为持续时间的格式类似于. 自从我开始需要变量的引号(ffprobe.exe 的路径在哪里)以来,这停止了工作。ffprobe%%vformat,94.436000%ffprobe%

batch ffprobe
  • 1 个回答
  • 145 Views
Martin Hope
Bricktop
Asked: 2021-09-07 04:34:30 +0800 CST

从任何硬盘驱动器中查找 exe 并将其设置为变量

  • 7

我有一种方法可以从任何驱动器中找到一个 exe 文件,而无需使用 %path%,但我需要将其设置为文件路径变量,而不仅仅是显示。

for %i in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do @%i: 2>nul && dir /s ffprobe.exe

任何生成的文件都可以设置为变量(如最后一个),但最新的(按日期或版本)将是最佳的。

--- 有关其他问题的更多信息 ---

for %%d in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do (
    @%%d: 2>nul && for /f "usebackq" %%f in (`dir /s /b ffprobe.exe`) do set "probe=%%f" && goto done
)

这是我使用答案构建的版本。由于某种原因,当路径中某处有空格时,它无法捕获整个文件路径。

environment-variables batch
  • 2 个回答
  • 162 Views
Martin Hope
Bricktop
Asked: 2020-06-21 13:55:05 +0800 CST

在高端 HTPC 上播放视频时出现持续延迟

  • 10

我有高端电脑,但无法流畅播放视频。我有 Intel Core i7 8700K、16gb RAM 和 GeForce GTX 1080。我的 PC 通过 DisplayPort 到 HDMI 电缆连接到 LG 75UM7110 电视。我必须使用这条电缆,因为这是在这个旧 GPU 上工作的唯一端口。电视已设置为 PC 使用的最大速度。这台机器我用了很长时间,播放非常流畅,即使是8k大部分时间也很流畅。最近发生的变化是电视和全新的 Windows 10 构建安装(以及 MPC-HC 版本更新)。

对于软件播放器,我的选择是 MPC-HC,并且不会为替代播放器提供想法。播放器设置为使用硬件加速(Playing [H/W]播放时显示,表示DXVA加速成功)。我在 HDD 上播放视频(也测试了 3500mb/s SSD)。视频流畅几秒钟,然后稍微滞后,重复。分辨率、高或低比特率或旧/新编解码器(从 XviD 到 x265)之间似乎没有任何区别。没有一个运行顺利,但很难判断滞后量是否不同。滞后不会延伸到玩游戏。在 4k x265 播放和大量空闲程序期间,我的 CPU 保持在 6-8%(MPC-HC 使用其中的 31-33%),我的 HDD 保持在 0-2%,GPU 保持在 12%。MPC-HC 内存使用量稳定在 326-328mb。

更新

我的一个朋友用他自己的电缆将他的笔记本电脑连接到我的 LG 电视,复制到另一个 HDMI 端口。问题没有出现在他的笔记本电脑屏幕上,只是重复输出到电视上。这些是我的一些电视设置:

  • 图片模式:游戏
  • 锐度:0
  • 动态对比度:关闭
  • 超分辨率:关闭
  • 眼睛舒适模式:关闭
  • 节能:关
  • HDMI 超高清深色:关闭
  • 人工智能推荐:关闭
windows-10 video-playback
  • 1 个回答
  • 1234 Views
Martin Hope
Bricktop
Asked: 2019-10-14 05:20:15 +0800 CST

打开一个弹出窗口进行多项选择?

  • 6

我正在编写一个batch运行视频播放列表的脚本,一个一个地打开它们,并要求在视频之间采取行动。有没有办法打开一个弹出窗口进行多项选择?如果不采取任何操作,此弹出窗口应在几秒钟内关闭,以便播放列表可以继续。没有本地 Microsoft 命令行工具可以做到这一点,正在寻找解决方法。

batch popups
  • 2 个回答
  • 346 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何减少“vmmem”进程的消耗?

    • 11 个回答
  • Marko Smith

    从 Microsoft Stream 下载视频

    • 4 个回答
  • Marko Smith

    Google Chrome DevTools 无法解析 SourceMap:chrome-extension

    • 6 个回答
  • Marko Smith

    Windows 照片查看器因为内存不足而无法运行?

    • 5 个回答
  • Marko Smith

    支持结束后如何激活 WindowsXP?

    • 6 个回答
  • Marko Smith

    远程桌面间歇性冻结

    • 7 个回答
  • Marko Smith

    子网掩码 /32 是什么意思?

    • 6 个回答
  • Marko Smith

    鼠标指针在 Windows 中按下的箭头键上移动?

    • 1 个回答
  • Marko Smith

    VirtualBox 无法以 VERR_NEM_VM_CREATE_FAILED 启动

    • 8 个回答
  • Marko Smith

    应用程序不会出现在 MacBook 的摄像头和麦克风隐私设置中

    • 5 个回答
  • Martin Hope
    Vickel Firefox 不再允许粘贴到 WhatsApp 网页中? 2023-08-18 05:04:35 +0800 CST
  • Martin Hope
    Saaru Lindestøkke 为什么使用 Python 的 tar 库时 tar.xz 文件比 macOS tar 小 15 倍? 2021-03-14 09:37:48 +0800 CST
  • Martin Hope
    CiaranWelsh 如何减少“vmmem”进程的消耗? 2020-06-10 02:06:58 +0800 CST
  • Martin Hope
    Jim Windows 10 搜索未加载,显示空白窗口 2020-02-06 03:28:26 +0800 CST
  • Martin Hope
    andre_ss6 远程桌面间歇性冻结 2019-09-11 12:56:40 +0800 CST
  • Martin Hope
    Riley Carney 为什么在 URL 后面加一个点会删除登录信息? 2019-08-06 10:59:24 +0800 CST
  • Martin Hope
    zdimension 鼠标指针在 Windows 中按下的箭头键上移动? 2019-08-04 06:39:57 +0800 CST
  • Martin Hope
    jonsca 我所有的 Firefox 附加组件突然被禁用了,我该如何重新启用它们? 2019-05-04 17:58:52 +0800 CST
  • Martin Hope
    MCK 是否可以使用文本创建二维码? 2019-04-02 06:32:14 +0800 CST
  • Martin Hope
    SoniEx2 更改 git init 默认分支名称 2019-04-01 06:16:56 +0800 CST

热门标签

windows-10 linux windows microsoft-excel networking ubuntu worksheet-function bash command-line hard-drive

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助
subwaysurfers
my femboy roommate

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve