使用批处理文件在服务器上查找文件夹名称 [英] Finding folder name on a server using batch file
问题描述
我正在尝试找到一种方法来定位某个文件夹.
I am trying to find a way how to locate a certain folder.
问题是我在给定时间内不知道确切的文件夹名称.
Problem is that I don't know exact folder name in given time.
因此,我希望根据日期(例如当天或应用程序完成时的17.50)找到基于正则表达式的文件夹.[请参见下面的示例]
So I am looking to find a folder based on regex, based on date, for example in 17.50 that day or the moment when application finish. [see example below]
/application/qa/log/r52d4/20201020/20201020-17.59.49_r52d4_testuser
因此,我用腻子试图连接到服务器并找到该文件夹名称,并将该文件夹名称保存在txt文件中,以备后用.
So with putty I am trying to connect to server and locate that folder name and save that folder name in a txt file for later usage.
pscp find / -type d -name 'r52d4' -P 22 -pw test_pw testuser@testserver:/ C:\saved_logs\folder_name.txt
我的问题是,这是否是解决此问题的正确方法,你们是否可以指出正确的方向?
My question is if this is the correct approach for solving this issue, and if you guys can point me in the right direction.
注意:我不需要寻找正确日期的帮助,只需正确的方法即可.
Note: I don't need help with finding correct date, just correct approach.
到目前为止,谷歌搜索并没有帮助我,我不确定是否必须先使用pscp登录,然后执行find方法还是需要将所有内容组合在一起:
So far came with this, google searches didn't help me, I am not sure if I have to first login with pscp and then execute find method or everything needs to be combined:
pscp -P 22 -pw test_pw testuser@testserver find . -type d -regextype sed -regex ".*/20201020-17\.5[0-9]\.[0-5][0-9]_r52d4.*"
推荐答案
您可以使用此命令(从17:50:00到17:59:59):
You can use this command (from 17:50:00 to 17:59:59):
$ find . -type d -regextype sed -regex ".*/20201020-17\.5[0-9]\.[0-5][0-9]_r52d4.*"
或者如果您只希望从17:50:00到17:50:59
Or this if you want only from 17:50:00 to 17:50:59
$ find . -type d -regextype sed -regex ".*/20201020-17\.50\.[0-5][0-9]_r52d4.*"
这篇关于使用批处理文件在服务器上查找文件夹名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!