0

根据标题,我可以使用批处理打开特定文件夹(始终相同)并输入搜索查询(在窗口右上角的搜索框框中)吗?

更多信息/最终目标:

我们有一个“项目”文件夹,其中包含我们每个项目的子文件夹列表。每个子文件夹名称都以作业编号开头,即:

356 - 22 圣刘易斯大道

357 - 104 Madeitup 广场

项目的发票文件(pdf)都单独存储在一个“发票”文件夹中。每个项目可能有多个发票,因此文件夹中的文件如下所示:

356-1.pdf

356-2.pdf

356-3.pdf

357-1.pdf

357-2.pdf

我的最终目标是能够在每个项目文件夹中拥有一个通用批处理文件,该文件将打开发票文件夹,并通过从项目文件夹名称中解析项目编号,将其输入到搜索框中并仅显示与该项目相关的发票.

4

3 回答 3

2

第一行获取批处理文件所在目录的名称,并将其存储在名为pd的变量中。第二行开始一个搜索查询,该查询在名为“...\invoice”的目录中搜索名称包含pd变量前 3 个字符的任何文件或文件夹(将其替换为实际Invoice目录的完整路径)。

for %%* in (.) do set "pd=%%~nx*"
start "" "search-ms:query=%pd:~0,3%&crumb=location:...\invoice&"
于 2017-05-10T17:28:48.117 回答
0
    SET HPATH="I:\Share\HOTLINE"
    SET /p DriverNb=Enter Driver Number: 
    start "" "search-ms:query=%DriverNb%&crumb=location:%HPATH%&"
于 2021-03-17T19:19:28.690 回答
0

批处理不起作用

批处理脚本并不意味着与 GUI 一起操作。对于所选工具,描述的目标似乎几乎不可能。也许,批处理可以解决一些重新制定的任务,例如将项目相关发票的软链接放入 tmp 文件夹,这样您就可以在一个地方看到它们。尽管如此,恕我直言,解决方案将非常庞大且痛苦。不过,有一个好消息:

AutoIt会做

AutoIt是一种免费软件,类似 BASIC 的脚本语言,旨在自动化 Windows GUI 和一般脚本。

准确描述行为的整个脚本总共用了 10 行(不包括评论):

;script is supposed to be run from root folder of any individual project
#include <File.au3>

;split full project path into array of folder names
Global $aProjFolderTree = StringSplit(@WorkingDir, "\/")
;get name of the last folder. It should be project name like "356 - 22 St. Lewes Avenue"
Global $sProjLastFolderName = $aProjFolderTree[$aProjFolderTree[0]]

;split project name into words
Global $aProjNameWords = StringSplit($sProjLastFolderName, " ")
;get the first word which is project ID like "356"
Global $sProjId = $aProjNameWords[1]

;open invoice directory in explorer
Global $sInvoiceFolder = _PathFull("..\invoice", @WorkingDir)
Run('explorer.exe ' & $sInvoiceFolder)
;wait until it's ready
WinWaitActive("invoice", "", 10)

;click onto "search" control. NB! control ID may differ on your system, use "AutoIt Window Info" tool to check
ControlClick( "[LAST]", "", "[CLASS:DirectUIHWND; INSTANCE:1]")
;put project Id into it
ControlSend( "[LAST]", "", "[CLASS:DirectUIHWND; INSTANCE:1]", $sProjId)

为了运行:

  • 安装 AutoIt
  • 在您的项目文件夹中创建script_name.au3文本文件并粘贴提供的代码
  • 双击

您可以将脚本打包成可执行文件,如果需要,它可以在没有 AutoIt 的机器上正常运行。

于 2017-05-10T17:29:26.710 回答