The original post for this would be:
Batch - Search for part/exact name and copy line from text file into batch as var
The solution provided was:
@echo off
set "file_name=V001-video_folder_6.mp4"
for /F "tokens=2 delims=-." %%A in ("%file_name%") do set "folder=%%A"
for /F "delims=" %%P in ('%SystemRoot%\System32\findstr.exe "/C:%folder%" Test.txt') do (
set "folder_path=%%P"
goto NextCommand
)
:NextCommand
echo Full folder path is: %folder_path%
However after testing for a few days, it works but under a very strict criteria. I would like to change that.
Here is a group of folder:
/var/www/xxx/html/videos/video_folder_1
/var/www/xxx/html/videos/video_folder_2
/var/www/xxx/html/videos/video_folder_3
/var/www/xxx/html/videos/video_folder_4
/var/www/xxx/html/videos/video_folder_5
/var/www/xxx/html/videos/video_folder_6
/var/www/xxx/html/videos/video_folder_7
This file V001-video_folder_6.mp4
is moved the appropriate folder i.e. /var/www/xxx/html/videos/video_folder_6
.
However. If I try these variations it does not work:
V001-video_folder_6.mp4
- WORKSV001 - video_folder_6.mp4
- DOES NOT WORKV001-video_folder_6.com.mp4
- DOES NOT WORK
The -
and .
are paramount for this to work.
Is there a way to get the batch code to look for the string video_folder_6
regardless of the stuff around it. e.g. V001 - Hello ___ video_folder_6 ok.....com.mp4
.