Just a quick reply, I'll look into subfolders in a bit. The way the script is set up, you specify the folders by running it with arguments from command prompt.
command prompt:
C:\>$a.bat "C:\test\1\2\3" "C:\test2"
copied 1.txt to "C:\test2"\test_1_2_3_1.txt
copied 2.txt to "C:\test2"\test_1_2_3_2.txt
copied 3.txt to "C:\test2"\test_1_2_3_3.txt
copied 4.txt to "C:\test2"\test_1_2_3_4.txt
copied 5.txt to "C:\test2"\test_1_2_3_5.txt
copied 6.txt to "C:\test2"\test_1_2_3_6.txt
copied 7.txt to "C:\test2"\test_1_2_3_7.txt
copied 8.txt to "C:\test2"\test_1_2_3_8.txt
copied 9.txt to "C:\test2"\test_1_2_3_9.txt
C:\>dir test2
Volume in drive C is Acer
Volume Serial Number is D0E0-609C
Directory of C:\test2
06/27/2013 09:57 AM <DIR> .
06/27/2013 09:57 AM <DIR> ..
06/27/2013 09:54 AM 3 test_1_2_3_1.txt
06/27/2013 09:54 AM 3 test_1_2_3_2.txt
06/27/2013 09:54 AM 3 test_1_2_3_3.txt
06/27/2013 09:54 AM 3 test_1_2_3_4.txt
06/27/2013 09:54 AM 3 test_1_2_3_5.txt
06/27/2013 09:54 AM 3 test_1_2_3_6.txt
06/27/2013 09:54 AM 3 test_1_2_3_7.txt
06/27/2013 09:54 AM 3 test_1_2_3_8.txt
06/27/2013 09:54 AM 3 test_1_2_3_9.txt
9 File(s) 27 bytes
2 Dir(s) 196,188,549,120 bytes free
C:\>
I will work on allowing for you to search by word, but you may have to edit the code every time.
EDIT:
This works for everything but searching, not sure how to do that.
:: $renameWithPath.bat <source path> <destination path> <extentions>
@echo off
setlocal EnableDelayedExpansion
cd %1
set ext=%3
for %%A in (*.!ext!) do (
set path=%%~pA
set "path=!path:\=_!"
set path=!path:~1,10000!
copy "%%A" "%2\!path!%%~nxA" >nul && echo copied %%A to %2\!path!%%~nxA
)
for /f "delims=" %%B in ('dir /b /a:d') do (
cd %%B
for %%A in (*.!ext!) do (
set path=%%~pA
set "path=!path:\=_!"
set path=!path:~1,10000!
copy "%%A" "%2\!path!%%~nxA" >nul && echo copied %%A to %2\!path!%%~nxA
)
cd ..
)