使用AutoHotkey读取目录中的文件名 [英] Read filenames in a directory with AutoHotkey

查看:484
本文介绍了使用AutoHotkey读取目录中的文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种读取文件夹并将每个文件名保存到变量的方法.到目前为止,这就是我所拥有的

I am looking for a way to read a folder and save each filename to a variable. So far this is what I have

Loop,C:\My Documents\Notes\*

在我的笔记目录中,我有pdf文件.我想读取目录并将文件名"Homework1.pdf"保存到变量,然后将文件本身移动到另一个目录.在下一个循环中,它将拾取下一个pdf文档"Test.pdf"等.这应该循环直到每个pdf被移动为止.

In my notes directory I have pdf files. I want to read the directory and save the filename "Homework1.pdf" to a variable then move the file itself to another directory. On the next loop it will pick up the next pdf document "Test.pdf" etc. This should loop until every pdf has been moved.

我知道我可以使用FileMove,但是样本显示您必须提供要移动的特定文件名.我该如何调整它以一个一个地移动每个pdf文件?

I know I could use FileMove but the samples show that you have to provide the specific filename to move. How can I adjust this to move each pdf file one by one?

推荐答案

您可以绕过创建要解析的列表(假设您不需要其他任何变量),并使用内置变量A_LoopFileFullPathA_LoopFileName为此.

You can bypass creating a list to parse (assuming you don't need the variables for anything else) and use the built-in variables A_LoopFileFullPath and A_LoopFileName to accomplish this.

Loop, C:\My Documents\Notes\*.pdf
    FileCopy, % A_LoopFileFullPath, C:\NewPath\%A_LoopFileName%

尝试此操作以预览结果

Loop, C:\My Documents\Notes\*.pdf
    Msgbox % A_LoopFileFullPath "`nC:\NewPath\" A_LoopFileName

这篇关于使用AutoHotkey读取目录中的文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆