Luis Diaz
asked on
VB Script Bat: search file based on a string name and a root folder
Hello experts,
I am looking for a script (batch or vbscript) in which I should be able to report/
-strFileNameString: (string name of my file)
-strRootFolder in which is located the the file that I am searching.
The script should be able to search recursively based on the strRootFolder specified in the script and report in a log-search file which are the locations (full folder patch) in which is located the file.
The idea is to report a string name such as toto and the script should be able to report the various location of files which contains toto based on the RootFolder reported in a log-search file
Example of log-search file:
toto_3747475757.ppt is located at: C:\Temp
toto_56F.txt is located at: C:\Temp\ongoing
Thank you very much for your help.
I am looking for a script (batch or vbscript) in which I should be able to report/
-strFileNameString: (string name of my file)
-strRootFolder in which is located the the file that I am searching.
The script should be able to search recursively based on the strRootFolder specified in the script and report in a log-search file which are the locations (full folder patch) in which is located the file.
The idea is to report a string name such as toto and the script should be able to report the various location of files which contains toto based on the RootFolder reported in a log-search file
Example of log-search file:
toto_3747475757.ppt is located at: C:\Temp
toto_56F.txt is located at: C:\Temp\ongoing
Thank you very much for your help.
ASKER
Thank you very much for this proposal.
I would like to specify within the script:
strRootFolder="C:\Search\r oot\"
strString="toto"
strLogSearch="201606031554 _Log_Searc h.log" (datestamp will be at the beginning of Log_Search, sorry I didn't specify at the beginning but I think it is useful)
And when I double click 201606031554_Log_Search.Lo g should be generated and report the various various files locations which contains the strString reported.
example of 201606031554_Log_Search.Lo g composition
201606031554>>>>toto_titi. xls found located at "C:\Search\root\folder1\te mp\"
201606031555>>>>toto-tati. ppt found located at "C:\Search\root\folder1\"
End of the search >>>>201606031558
......
If the script didn't found anything it should also report:
Not files found with the reported string "toto" in the reported root folder "C:\Search\root\"
End of the search >>>>201606031554
Thank you again for your help.
I would like to specify within the script:
strRootFolder="C:\Search\r
strString="toto"
strLogSearch="201606031554
And when I double click 201606031554_Log_Search.Lo
example of 201606031554_Log_Search.Lo
201606031554>>>>toto_titi.
201606031555>>>>toto-tati.
End of the search >>>>201606031558
......
If the script didn't found anything it should also report:
Not files found with the reported string "toto" in the reported root folder "C:\Search\root\"
End of the search >>>>201606031554
Thank you again for your help.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you very much for this proposal. I was traveling, I will take the time to test it this week.
ASKER
I am really sorry for the delay.
I tested your lastd proposal and it works perfectly.
I have just a smal remark. In order to properly read the log file is there a way to insert a "return to the line" when I have:
>>>>datestamp
Or insert line break in order to make the difference between the first sentence Start and the path location reported by the script?
The idea is to have something like this:
Thank you again for y our help.
I tested your lastd proposal and it works perfectly.
I have just a smal remark. In order to properly read the log file is there a way to insert a "return to the line" when I have:
>>>>datestamp
Or insert line break in order to make the difference between the first sentence Start and the path location reported by the script?
The idea is to have something like this:
Thank you again for y our help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Tested and it works perfectly!!!!!!
Thank you again for your help.
Thank you again for your help.
Open in new window
Or do you need more complex search patterns, or want the search root hard coded, or just double-click, or some such?And if you want it as script, should the arguments be passed in the command line, be hard coded in the script, be queried for (note: no tab completion for the folder path, like in the command line)?