cunoc
asked on
Search "My TXT-FILES Folder" from Drive (A:) to Drive (Z:), then parse the direcory listing into the MENU systems
Hi all Experts,
I love to have a script that will:
1. Search "My TXT-FILES Folder" from Drive (A:) to Drive (Z:).
2. Assume it was found in Drive D or E, then stop searching.
3. Begin to parse the directory listing into the MENU systems.
4. Then, I can choose a "Folder" that I want to see what in there.
5. Another MENU appears, from there, I can choose a file to view.
6. Even I closed the file I just view, The menu need to be there,
so I can go back and forth to open other folders or files,
if needed.
"My TXT-FILES Folder"
Folder 1
My Note 01.txt
Your note 01.txt
Folder 2
Output.txt
Input.txt
Folder 3
Temp.txt
List.txt
-------------------------- ------
MAIN MENU
-------------------------- ------
1. Folder 1
2. Folder 2
3. Folder 3
4. Exit
Enter your selection __
-------------------------- ------
If choose option 1, then another MENU appears.
-------------------------- ------
Folder 1
-------------------------- ------
1. My Note 01.txt
2. Your note 01.txt
3. Back to Main Menu
Enter your selection __
-------------------------- ------
If choose option 2, then call "Notepad.exe" to open "Your note 01.txt"
and so on ...
I love to have a script that will:
1. Search "My TXT-FILES Folder" from Drive (A:) to Drive (Z:).
2. Assume it was found in Drive D or E, then stop searching.
3. Begin to parse the directory listing into the MENU systems.
4. Then, I can choose a "Folder" that I want to see what in there.
5. Another MENU appears, from there, I can choose a file to view.
6. Even I closed the file I just view, The menu need to be there,
so I can go back and forth to open other folders or files,
if needed.
"My TXT-FILES Folder"
Folder 1
My Note 01.txt
Your note 01.txt
Folder 2
Output.txt
Input.txt
Folder 3
Temp.txt
List.txt
--------------------------
MAIN MENU
--------------------------
1. Folder 1
2. Folder 2
3. Folder 3
4. Exit
Enter your selection __
--------------------------
If choose option 1, then another MENU appears.
--------------------------
Folder 1
--------------------------
1. My Note 01.txt
2. Your note 01.txt
3. Back to Main Menu
Enter your selection __
--------------------------
If choose option 2, then call "Notepad.exe" to open "Your note 01.txt"
and so on ...
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi t0t0,
I don't want it to automatically to search from Drive A: - Drive Z, without asking me .. and the script doesn't work.
////////////////////////// //
Searching drive
a
The system cannot find the path specified.
b
The system cannot find the path specified.
d
The device is not ready.
e
The device is not ready.
f
g
The device is not ready.
h
The device is not ready.
i
The device is not ready.
j
k
File Not Found
l
m
n
o
////////////////////////// ///////
:: ========================== ========== ========== ========== ========== ========== =====
:: TXTMenu
::
:: Written by Paul Tomasi - 11/01/1010
:: ========================== ========== ========== ========== ========== ========== =====
@echo off
setlocal enabledelayedexpansion
echo.
set /p .=Searching drive
for %%a in (a b d e f g h i j k l m n o p q r s t u v w x y z) do (
set /p .=%%a
for /f "tokens=*" %%b in ('dir /ad /b %%a:\') do (
if /i "%%~nb"=="My TXT-FILES" (
set source=%%~db
set folder=0
for /f "tokens=*" %%a in ('dir /ad /b %source%') do (
set /a folder+=1
set folder[!folder!]=%%a
)
set /a folder+=1
set folder[!folder!]=Exit
goto :menu
)
)
)
echo Cannot find "My TXT-FILES" folder.
exit /b
:: -------------------------- ---------- ---------- ---------- ---------- ---------- -----
:: MENU
:: -------------------------- ---------- ---------- ---------- ---------- ---------- -----
:menu
cls
echo -------------------------- ------
echo MAIN MENU
echo -------------------------- ------
for /l %%a in (1,1,%folder%) do (
echo %%a. !folder[%%a]!
)
echo.
set /p selected_folder=Enter your selection:
for %%a in (%selected_folder%) do (
if "!folder[%%a]!"=="" (
echo.
echo Please select from 1..!folder!
echo.
pause
) else (
if /i "!folder[%%a]!"=="Exit" (
echo.
echo Goodbye.
exit /b
) else (
call :list_files "!folder[%%a]!"
)
)
)
goto :menu
:: -------------------------- ---------- ---------- ---------- ---------- ---------- -----
:: LIST FILES
:: -------------------------- ---------- ---------- ---------- ---------- ---------- -----
:list_files
set file=0
for /f "tokens=*" %%a in ('dir /a-d /b "%~1\*.txt"') do (
set /a file+=1
set file[!file!]=%%~nxa
)
set /a file+=1
set file[%file%]=Back to Main Menu
:loop
cls
echo -------------------------- ------
echo %~1
echo -------------------------- ------
for /l %%a in (1,1,%file%) do (
echo %%a. !file[%%a]!
)
echo.
set /p selected_file=Enter your selection:
for %%a in (%selected_file%) do (
if "!file[%%a]!"=="" (
echo.
echo Please select from 1..!file!
echo.
pause
) else (
if /i "!file[%%a]!"=="Back to Main Menu" (
exit /b
) else (
notepad "%~1\!file[%%a]!"
)
)
)
goto :loop
I don't want it to automatically to search from Drive A: - Drive Z, without asking me .. and the script doesn't work.
//////////////////////////
Searching drive
a
The system cannot find the path specified.
b
The system cannot find the path specified.
d
The device is not ready.
e
The device is not ready.
f
g
The device is not ready.
h
The device is not ready.
i
The device is not ready.
j
k
File Not Found
l
m
n
o
//////////////////////////
:: ==========================
:: TXTMenu
::
:: Written by Paul Tomasi - 11/01/1010
:: ==========================
@echo off
setlocal enabledelayedexpansion
echo.
set /p .=Searching drive
for %%a in (a b d e f g h i j k l m n o p q r s t u v w x y z) do (
set /p .=%%a
for /f "tokens=*" %%b in ('dir /ad /b %%a:\') do (
if /i "%%~nb"=="My TXT-FILES" (
set source=%%~db
set folder=0
for /f "tokens=*" %%a in ('dir /ad /b %source%') do (
set /a folder+=1
set folder[!folder!]=%%a
)
set /a folder+=1
set folder[!folder!]=Exit
goto :menu
)
)
)
echo Cannot find "My TXT-FILES" folder.
exit /b
:: --------------------------
:: MENU
:: --------------------------
:menu
cls
echo --------------------------
echo MAIN MENU
echo --------------------------
for /l %%a in (1,1,%folder%) do (
echo %%a. !folder[%%a]!
)
echo.
set /p selected_folder=Enter your selection:
for %%a in (%selected_folder%) do (
if "!folder[%%a]!"=="" (
echo.
echo Please select from 1..!folder!
echo.
pause
) else (
if /i "!folder[%%a]!"=="Exit" (
echo.
echo Goodbye.
exit /b
) else (
call :list_files "!folder[%%a]!"
)
)
)
goto :menu
:: --------------------------
:: LIST FILES
:: --------------------------
:list_files
set file=0
for /f "tokens=*" %%a in ('dir /a-d /b "%~1\*.txt"') do (
set /a file+=1
set file[!file!]=%%~nxa
)
set /a file+=1
set file[%file%]=Back to Main Menu
:loop
cls
echo --------------------------
echo %~1
echo --------------------------
for /l %%a in (1,1,%file%) do (
echo %%a. !file[%%a]!
)
echo.
set /p selected_file=Enter your selection:
for %%a in (%selected_file%) do (
if "!file[%%a]!"=="" (
echo.
echo Please select from 1..!file!
echo.
pause
) else (
if /i "!file[%%a]!"=="Back to Main Menu" (
exit /b
) else (
notepad "%~1\!file[%%a]!"
)
)
)
goto :loop
ASKER
Hi t0t0,
I want it to automatically to search from Drive A: - Drive Z, without asking me .. and the script doesn't work.
I want it to automatically to search from Drive A: - Drive Z, without asking me .. and the script doesn't work.
ASKER
Hi t0t0,
I modified (set /p .=Searching drive <nul) to (set p .=Searching drive) and (set /p .=%%a) to (set p .=%%a), the script does run a search but could not find any ... even I have assigned the correct "TXT, Removable0001" for searching ...
:: ========================== ========== ========== ========== ========== ========== =====
:: TXTMenu
::
:: Written by Paul Tomasi - 11/01/1010
:: ========================== ========== ========== ========== ========== ========== =====
@echo off
setlocal enabledelayedexpansion
echo.
set p .=Searching drive
for %%a in (a b d e f g h i j k l m n o p q r s t u v w x y z) do (
set p .=%%a
for /f "tokens=*" %%b in ('dir /ad /b %%a:\') do (
if /i "%%~nb"=="TXT, Removable0001" (
set source=%%~db
set folder=0
for /f "tokens=*" %%a in ('dir /ad /b %source%') do (
set /a folder+=1
set folder[!folder!]=%%a
)
set /a folder+=1
set folder[!folder!]=Exit
goto :menu
)
)
)
echo Cannot find "My TXT-FILES" folder.
exit /b
:: -------------------------- ---------- ---------- ---------- ---------- ---------- -----
:: MENU
:: -------------------------- ---------- ---------- ---------- ---------- ---------- -----
:menu
cls
echo -------------------------- ------
echo MAIN MENU
echo -------------------------- ------
for /l %%a in (1,1,%folder%) do (
echo %%a. !folder[%%a]!
)
echo.
set /p selected_folder=Enter your selection:
for %%a in (%selected_folder%) do (
if "!folder[%%a]!"=="" (
echo.
echo Please select from 1..!folder!
echo.
pause
) else (
if /i "!folder[%%a]!"=="Exit" (
echo.
echo Goodbye.
exit /b
) else (
call :list_files "!folder[%%a]!"
)
)
)
goto :menu
:: -------------------------- ---------- ---------- ---------- ---------- ---------- -----
:: LIST FILES
:: -------------------------- ---------- ---------- ---------- ---------- ---------- -----
:list_files
set file=0
for /f "tokens=*" %%a in ('dir /a-d /b "%~1\*.txt"') do (
set /a file+=1
set file[!file!]=%%~nxa
)
set /a file+=1
set file[%file%]=Back to Main Menu
:loop
cls
echo -------------------------- ------
echo %~1
echo -------------------------- ------
for /l %%a in (1,1,%file%) do (
echo %%a. !file[%%a]!
)
echo.
set /p selected_file=Enter your selection:
for %%a in (%selected_file%) do (
if "!file[%%a]!"=="" (
echo.
echo Please select from 1..!file!
echo.
pause
) else (
if /i "!file[%%a]!"=="Back to Main Menu" (
exit /b
) else (
notepad "%~1\!file[%%a]!"
)
)
)
goto :loop
I modified (set /p .=Searching drive <nul) to (set p .=Searching drive) and (set /p .=%%a) to (set p .=%%a), the script does run a search but could not find any ... even I have assigned the correct "TXT, Removable0001" for searching ...
:: ==========================
:: TXTMenu
::
:: Written by Paul Tomasi - 11/01/1010
:: ==========================
@echo off
setlocal enabledelayedexpansion
echo.
set p .=Searching drive
for %%a in (a b d e f g h i j k l m n o p q r s t u v w x y z) do (
set p .=%%a
for /f "tokens=*" %%b in ('dir /ad /b %%a:\') do (
if /i "%%~nb"=="TXT, Removable0001" (
set source=%%~db
set folder=0
for /f "tokens=*" %%a in ('dir /ad /b %source%') do (
set /a folder+=1
set folder[!folder!]=%%a
)
set /a folder+=1
set folder[!folder!]=Exit
goto :menu
)
)
)
echo Cannot find "My TXT-FILES" folder.
exit /b
:: --------------------------
:: MENU
:: --------------------------
:menu
cls
echo --------------------------
echo MAIN MENU
echo --------------------------
for /l %%a in (1,1,%folder%) do (
echo %%a. !folder[%%a]!
)
echo.
set /p selected_folder=Enter your selection:
for %%a in (%selected_folder%) do (
if "!folder[%%a]!"=="" (
echo.
echo Please select from 1..!folder!
echo.
pause
) else (
if /i "!folder[%%a]!"=="Exit" (
echo.
echo Goodbye.
exit /b
) else (
call :list_files "!folder[%%a]!"
)
)
)
goto :menu
:: --------------------------
:: LIST FILES
:: --------------------------
:list_files
set file=0
for /f "tokens=*" %%a in ('dir /a-d /b "%~1\*.txt"') do (
set /a file+=1
set file[!file!]=%%~nxa
)
set /a file+=1
set file[%file%]=Back to Main Menu
:loop
cls
echo --------------------------
echo %~1
echo --------------------------
for /l %%a in (1,1,%file%) do (
echo %%a. !file[%%a]!
)
echo.
set /p selected_file=Enter your selection:
for %%a in (%selected_file%) do (
if "!file[%%a]!"=="" (
echo.
echo Please select from 1..!file!
echo.
pause
) else (
if /i "!file[%%a]!"=="Back to Main Menu" (
exit /b
) else (
notepad "%~1\!file[%%a]!"
)
)
)
goto :loop
ASKER
Hi t0t0,
I test again and the script is not be able to find the "TXT, Removable0001" that I am looking for ..
========================== ========== ========== ========== ========== ========== =====
:: TXTMenu
::
:: Written by Paul Tomasi - 11/01/1010
:: ========================== ========== ========== ========== ========== ========== =====
@echo off
setlocal enabledelayedexpansion
echo.
set p .=Searching drive
for %%a in (a b d e f g h i j k l m n o p q r s t u v w x y z) do (
set p .=%%a
for /f "tokens=*" %%b in ('dir /ad /b %%a:\') do (
if /i "%%~nb"=="TXT, Removable0001" (
set source=%%~db
set folder=0
for /f "tokens=*" %%a in ('dir /ad /b %source%') do (
set /a folder+=1
set folder[!folder!]=%%a
)
set /a folder+=1
set folder[!folder!]=Exit
goto :menu
)
)
)
echo Cannot find "TXT, Removable0001" folder.
pause ..
The system cannot find the path specified.
The system cannot find the path specified.
The device is not ready.
The device is not ready.
The device is not ready.
The device is not ready.
The device is not ready.
File Not Found
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
Cannot find "TXT, Removable0001" folder.
Press any key to continue . . .
I test again and the script is not be able to find the "TXT, Removable0001" that I am looking for ..
==========================
:: TXTMenu
::
:: Written by Paul Tomasi - 11/01/1010
:: ==========================
@echo off
setlocal enabledelayedexpansion
echo.
set p .=Searching drive
for %%a in (a b d e f g h i j k l m n o p q r s t u v w x y z) do (
set p .=%%a
for /f "tokens=*" %%b in ('dir /ad /b %%a:\') do (
if /i "%%~nb"=="TXT, Removable0001" (
set source=%%~db
set folder=0
for /f "tokens=*" %%a in ('dir /ad /b %source%') do (
set /a folder+=1
set folder[!folder!]=%%a
)
set /a folder+=1
set folder[!folder!]=Exit
goto :menu
)
)
)
echo Cannot find "TXT, Removable0001" folder.
pause ..
The system cannot find the path specified.
The system cannot find the path specified.
The device is not ready.
The device is not ready.
The device is not ready.
The device is not ready.
The device is not ready.
File Not Found
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
Cannot find "TXT, Removable0001" folder.
Press any key to continue . . .
Hi, quick question....
Would it suitable (as a huge shortcut), to have a script search for your specific folder on all drives, and when found, just open up Windows Explorer *at* that folder?
Then, you can just use Windows Explorer to navigate from there through the subfolders?
Rob.
Would it suitable (as a huge shortcut), to have a script search for your specific folder on all drives, and when found, just open up Windows Explorer *at* that folder?
Then, you can just use Windows Explorer to navigate from there through the subfolders?
Rob.
ASKER
Hi Rob Sampson,
I like the menu that t0t0 has design, the only problem is that that script fail to search the folder.
To answer to your question, if your design similar to t0t0's script, i like it. As long as it works base on script itself.
Thanks,
I like the menu that t0t0 has design, the only problem is that that script fail to search the folder.
To answer to your question, if your design similar to t0t0's script, i like it. As long as it works base on script itself.
Thanks,
cunoc
Hiya... I've just returned home to find all your comments which I have yet to read through.
One thing I must emphasise at this moment though is that my code is designed to search from drive C: upwards. Drive A: and B: would be treated differently due to the way the software hooks into the hardware.
I need a little time to look into this further.....
Hiya... I've just returned home to find all your comments which I have yet to read through.
One thing I must emphasise at this moment though is that my code is designed to search from drive C: upwards. Drive A: and B: would be treated differently due to the way the software hooks into the hardware.
I need a little time to look into this further.....
OK, this is VBS code, but give it a shot and see what you think.
Copy the code into Notepad, and save it as something like "FindFolder.vbs", then double click it to run it.
Regards,
Rob.
Copy the code into Notepad, and save it as something like "FindFolder.vbs", then double click it to run it.
Regards,
Rob.
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const intForReading = 1
Set objShell = CreateObject("WScript.Shell")
strFolderName = "My TXT-FILES"
strTempFile = "c:\temp\result.txt"
strFoundFolderPath = ""
If objFSO.FileExists(strTempFile) = True Then objFSO.DeleteFile strTempFile, True
For intChr = 1 To 26
strDrive = Chr(intChr + 64) & ":"
If objFSO.DriveExists(strDrive) = True Then
objShell.Run "cmd /c dir /ad /s /b c:\""*" & strFolderName & "*"" > " & strTempFile, 0, True
If objFSO.FileExists(strTempFile) = True Then
Set objFile = objFSO.OpenTextFile(strTempFile, intForReading, False)
If Not objFile.AtEndOfStream Then strFoundFolderPath = objFile.ReadLine
End If
End If
If strFoundFolderPath <> "" Then Exit For
Next
If strFoundFolderPath = "" Then
MsgBox "Folder was not found."
Else
objShell.Run "explorer.exe /n,/e,""" & strFoundFolderPath & """", 1, False
End If
ASKER
Hi RobSampson:
Your script only search in drive C:\ and the result was "Folder was not found."
Thanks
//////////////
Set objFSO = CreateObject("Scripting.Fi leSystemOb ject")
Const intForReading = 1
Set objShell = CreateObject("WScript.Shel l")
strFolderName = "TXT, Removable0001"
strTempFile = "c:\temp\result.txt"
strFoundFolderPath = ""
If objFSO.FileExists(strTempF ile) = True Then objFSO.DeleteFile strTempFile, True
For intChr = 1 To 26
strDrive = Chr(intChr + 64) & ":"
If objFSO.DriveExists(strDriv e) = True Then
objShell.Run "cmd /c dir /ad /s /b c:\""*" & strFolderName & "*"" > " & strTempFile, 0, True
If objFSO.FileExists(strTempF ile) = True Then
Set objFile = objFSO.OpenTextFile(strTem pFile, intForReading, False)
If Not objFile.AtEndOfStream Then strFoundFolderPath = objFile.ReadLine
End If
End If
If strFoundFolderPath <> "" Then Exit For
Next
If strFoundFolderPath = "" Then
MsgBox "Folder was not found."
Else
objShell.Run "explorer.exe /n,/e,""" & strFoundFolderPath & """", 1, False
End If
Your script only search in drive C:\ and the result was "Folder was not found."
Thanks
//////////////
Set objFSO = CreateObject("Scripting.Fi
Const intForReading = 1
Set objShell = CreateObject("WScript.Shel
strFolderName = "TXT, Removable0001"
strTempFile = "c:\temp\result.txt"
strFoundFolderPath = ""
If objFSO.FileExists(strTempF
For intChr = 1 To 26
strDrive = Chr(intChr + 64) & ":"
If objFSO.DriveExists(strDriv
objShell.Run "cmd /c dir /ad /s /b c:\""*" & strFolderName & "*"" > " & strTempFile, 0, True
If objFSO.FileExists(strTempF
Set objFile = objFSO.OpenTextFile(strTem
If Not objFile.AtEndOfStream Then strFoundFolderPath = objFile.ReadLine
End If
End If
If strFoundFolderPath <> "" Then Exit For
Next
If strFoundFolderPath = "" Then
MsgBox "Folder was not found."
Else
objShell.Run "explorer.exe /n,/e,""" & strFoundFolderPath & """", 1, False
End If
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Hi RobSampson:
The script was able to find the "My TXT-FILES" then open Explorer, I was hoping that it would parse the directory listing into the MENU systems and so on.
Thanks
3. Begin to parse the directory listing into the MENU systems.
4. Then, I can choose a "Folder" that I want to see what in there.
5. Another MENU appears, from there, I can choose a file to view.
6. Even I closed the file I just view, The menu need to be there,
so I can go back and forth to open other folders or files,
if needed.
"My TXT-FILES Folder"
Folder 1
My Note 01.txt
Your note 01.txt
Folder 2
Output.txt
Input.txt
Folder 3
Temp.txt
List.txt
-------------------------- ------
MAIN MENU
-------------------------- ------
1. Folder 1
2. Folder 2
3. Folder 3
4. Exit
Enter your selection __
-------------------------- ------
If choose option 1, then another MENU appears.
-------------------------- ------
Folder 1
-------------------------- ------
1. My Note 01.txt
2. Your note 01.txt
3. Back to Main Menu
Enter your selection __
-------------------------- ------
If choose option 2, then call "Notepad.exe" to open "Your note 01.txt"
and so on ...
The script was able to find the "My TXT-FILES" then open Explorer, I was hoping that it would parse the directory listing into the MENU systems and so on.
Thanks
3. Begin to parse the directory listing into the MENU systems.
4. Then, I can choose a "Folder" that I want to see what in there.
5. Another MENU appears, from there, I can choose a file to view.
6. Even I closed the file I just view, The menu need to be there,
so I can go back and forth to open other folders or files,
if needed.
"My TXT-FILES Folder"
Folder 1
My Note 01.txt
Your note 01.txt
Folder 2
Output.txt
Input.txt
Folder 3
Temp.txt
List.txt
--------------------------
MAIN MENU
--------------------------
1. Folder 1
2. Folder 2
3. Folder 3
4. Exit
Enter your selection __
--------------------------
If choose option 1, then another MENU appears.
--------------------------
Folder 1
--------------------------
1. My Note 01.txt
2. Your note 01.txt
3. Back to Main Menu
Enter your selection __
--------------------------
If choose option 2, then call "Notepad.exe" to open "Your note 01.txt"
and so on ...
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi t0t0,
Sorry, I mess up your script when I test it, but now I run the original you sent over me and here is the output.
Here what I have changed ..
1. if /i "%%~nb"=="TXT, Removable0001" (
2. echo Cannot find "My TXT-FILES" folder.
PAUSE ..
exit /b
3. Cannot find "My TXT-FILES" folder.
Press any key to continue . . .
////////////////////////// ///////
@echo off
setlocal enabledelayedexpansion
echo.
set /p .=Searching drive <nul
for %%a in (a b d e f g h i j k l m n o p q r s t u v w x y z) do (
set /p .=%%a:...<nul
for /f "tokens=*" %%b in ('dir /ad /b %%a:\ 2^>nul') do (
if /i "%%~nb"=="TXT, Removable0001" (
set source=%%~db
set folder=0
for /f "tokens=*" %%a in ('dir /ad /b %source%') do (
set /a folder+=1
set folder[!folder!]=%%a
)
set /a folder+=1
set folder[!folder!]=Exit
goto :menu
)
)
)
echo Cannot find "My TXT-FILES" folder.
PAUSE ..
exit /b
:: -------------------------- ---------- ---------- ---------- ---------- ---------- -----
:: MENU
:: -------------------------- ---------- ---------- ---------- ---------- ---------- -----
:menu
cls
echo -------------------------- ------
echo MAIN MENU
echo -------------------------- ------
for /l %%a in (1,1,%folder%) do (
echo %%a. !folder[%%a]!
)
echo.
set /p selected_folder=Enter your selection:
for %%a in (%selected_folder%) do (
if "!folder[%%a]!"=="" (
echo.
echo Please select from 1..!folder!
echo.
pause
) else (
if /i "!folder[%%a]!"=="Exit" (
echo.
echo Goodbye.
exit /b
) else (
call :list_files "!folder[%%a]!"
)
)
)
goto :menu
:: -------------------------- ---------- ---------- ---------- ---------- ---------- -----
:: LIST FILES
:: -------------------------- ---------- ---------- ---------- ---------- ---------- -----
:list_files
set file=0
for /f "tokens=*" %%a in ('dir /a-d /b "%~1\*.txt"') do (
set /a file+=1
set file[!file!]=%%~nxa
)
set /a file+=1
set file[%file%]=Back to Main Menu
:loop
cls
echo -------------------------- ------
echo %~1
echo -------------------------- ------
for /l %%a in (1,1,%file%) do (
echo %%a. !file[%%a]!
)
echo.
set /p selected_file=Enter your selection:
for %%a in (%selected_file%) do (
if "!file[%%a]!"=="" (
echo.
echo Please select from 1..!file!
echo.
pause
) else (
if /i "!file[%%a]!"=="Back to Main Menu" (
exit /b
) else (
notepad "%~1\!file[%%a]!"
)
)
)
goto :loop
::
Sorry, I mess up your script when I test it, but now I run the original you sent over me and here is the output.
Here what I have changed ..
1. if /i "%%~nb"=="TXT, Removable0001" (
2. echo Cannot find "My TXT-FILES" folder.
PAUSE ..
exit /b
3. Cannot find "My TXT-FILES" folder.
Press any key to continue . . .
//////////////////////////
@echo off
setlocal enabledelayedexpansion
echo.
set /p .=Searching drive <nul
for %%a in (a b d e f g h i j k l m n o p q r s t u v w x y z) do (
set /p .=%%a:...<nul
for /f "tokens=*" %%b in ('dir /ad /b %%a:\ 2^>nul') do (
if /i "%%~nb"=="TXT, Removable0001" (
set source=%%~db
set folder=0
for /f "tokens=*" %%a in ('dir /ad /b %source%') do (
set /a folder+=1
set folder[!folder!]=%%a
)
set /a folder+=1
set folder[!folder!]=Exit
goto :menu
)
)
)
echo Cannot find "My TXT-FILES" folder.
PAUSE ..
exit /b
:: --------------------------
:: MENU
:: --------------------------
:menu
cls
echo --------------------------
echo MAIN MENU
echo --------------------------
for /l %%a in (1,1,%folder%) do (
echo %%a. !folder[%%a]!
)
echo.
set /p selected_folder=Enter your selection:
for %%a in (%selected_folder%) do (
if "!folder[%%a]!"=="" (
echo.
echo Please select from 1..!folder!
echo.
pause
) else (
if /i "!folder[%%a]!"=="Exit" (
echo.
echo Goodbye.
exit /b
) else (
call :list_files "!folder[%%a]!"
)
)
)
goto :menu
:: --------------------------
:: LIST FILES
:: --------------------------
:list_files
set file=0
for /f "tokens=*" %%a in ('dir /a-d /b "%~1\*.txt"') do (
set /a file+=1
set file[!file!]=%%~nxa
)
set /a file+=1
set file[%file%]=Back to Main Menu
:loop
cls
echo --------------------------
echo %~1
echo --------------------------
for /l %%a in (1,1,%file%) do (
echo %%a. !file[%%a]!
)
echo.
set /p selected_file=Enter your selection:
for %%a in (%selected_file%) do (
if "!file[%%a]!"=="" (
echo.
echo Please select from 1..!file!
echo.
pause
) else (
if /i "!file[%%a]!"=="Back to Main Menu" (
exit /b
) else (
notepad "%~1\!file[%%a]!"
)
)
)
goto :loop
::
ASKER
Hi t0t0,
I did try a few diffrent folders that I have in the drives and it not be able to find one.
1. if /i "%%~nb"=="TXT0001" (
2. if /i "%%~nb"=="TXT0002" (
3. if /i "%%~nb"=="TXT, Removable0001" (
I did try a few diffrent folders that I have in the drives and it not be able to find one.
1. if /i "%%~nb"=="TXT0001" (
2. if /i "%%~nb"=="TXT0002" (
3. if /i "%%~nb"=="TXT, Removable0001" (
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi t0t0,
I took out this line: for /f "tokens=*" %%b in ('dir /ad /b %%a:\ 2^>nul') do (
Replaced with this: for /f "tokens=*" %%b in ('dir /ad /b %%a:\') do (
/////////
Searching drive The system cannot find the path specified.
The system cannot find the path specified.
The device is not ready.
The device is not ready.
The device is not ready.
The device is not ready.
The device is not ready.
File Not Found
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
Cannot find "My TXT-FILES" folder.
Press any key to continue . . .
I took out this line: for /f "tokens=*" %%b in ('dir /ad /b %%a:\ 2^>nul') do (
Replaced with this: for /f "tokens=*" %%b in ('dir /ad /b %%a:\') do (
/////////
Searching drive The system cannot find the path specified.
The system cannot find the path specified.
The device is not ready.
The device is not ready.
The device is not ready.
The device is not ready.
The device is not ready.
File Not Found
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
Cannot find "My TXT-FILES" folder.
Press any key to continue . . .
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi t0t0,
I tried both..
1. if /i "%%~nb"=="TXT, Removable0001" (
2. if /i "%%~nb"==TXT, Removable0001 (
To answer to your question, My statement in the Ticket 26288431 was that I love your script, it great, the only problem was that it could not find the folder i am looking for.
And the reason I modified some part of your scrip was that I want to figure out where it stop and how far it goes to .... I did not mean your script doesn't work. Please accept my explanation...
Thanks,
I tried both..
1. if /i "%%~nb"=="TXT, Removable0001" (
2. if /i "%%~nb"==TXT, Removable0001 (
To answer to your question, My statement in the Ticket 26288431 was that I love your script, it great, the only problem was that it could not find the folder i am looking for.
And the reason I modified some part of your scrip was that I want to figure out where it stop and how far it goes to .... I did not mean your script doesn't work. Please accept my explanation...
Thanks,
ASKER
Hi t0t0,
It works and only works when I placed that script inside the directory of TXT, Removable0001
-------------------------- ------
MAIN MENU
-------------------------- ------
1. Shell Scripts 0001
2. TXT, Account0001
3. TXT, Adapter0001
4. TXT, Cisco 0001
5. TXT, Computer 0001
6. TXT, DVD0001
7. TXT, Linux n Unix 0001
8. TXT, Mix 0001
9. TXT, Movie AVI0001
10. TXT, Quiz0001
11. TXT_Text_File_0001
12. ViceVersa PRO, Backup0001
13. Exit
Enter your selection:
It works and only works when I placed that script inside the directory of TXT, Removable0001
--------------------------
MAIN MENU
--------------------------
1. Shell Scripts 0001
2. TXT, Account0001
3. TXT, Adapter0001
4. TXT, Cisco 0001
5. TXT, Computer 0001
6. TXT, DVD0001
7. TXT, Linux n Unix 0001
8. TXT, Mix 0001
9. TXT, Movie AVI0001
10. TXT, Quiz0001
11. TXT_Text_File_0001
12. ViceVersa PRO, Backup0001
13. Exit
Enter your selection:
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Paul Tomasi,
1. I changed (exit /b) in your script to PAUSE .. for testing purpose ..
2. It searchs all the way down to Z, then Message shown that "Can not find ..."
/////////////////
Searching drive z:...
Cannot find "TXT, Removable0001" folder.
Press any key to continue . . .
========================== ========== ========== ========== ========== ========== =====
:: TXTMenu
::
:: Written by Paul Tomasi - 11/01/1010
:: ========================== ========== ========== ========== ========== ========== =====
@echo off
setlocal enabledelayedexpansion
echo.
set /p .=Searching drive <nul
for %%a in (a b d e f g h i j k l m n o p q r s t u v w x y z) do (
set /p .=%%a:...<nul
for /f "tokens=*" %%b in ('dir /ad /b %%a:\ 2^>nul') do (
if /i "%%~nb"=="TXT, Removable0001" (
set source=%%a:
set folder=0
for /f "tokens=*" %%a in ('dir /ad /b /on "!source!\TXT, Removable0001\"') do (
set /a folder+=1
set folder[!folder!]=%%a
)
set /a folder+=1
set folder[!folder!]=Exit
goto :menu
)
)
)
echo.
echo.
echo Cannot find "TXT, Removable0001" folder.
PAUSE ..
::exit /b
:: -------------------------- ---------- ---------- ---------- ---------- ---------- -----
:: MENU
:: -------------------------- ---------- ---------- ---------- ---------- ---------- -----
:menu
cls
echo -------------------------- ------
echo MAIN MENU
echo -------------------------- ------
for /l %%a in (1,1,%folder%) do (
echo %%a. !folder[%%a]!
)
echo.
set /p selected_folder=Enter your selection:
for %%a in (%selected_folder%) do (
if "!folder[%%a]!"=="" (
echo.
echo Please select from 1..!folder!
echo.
pause
) else (
if /i "!folder[%%a]!"=="Exit" (
echo.
echo Goodbye.
exit /b
) else (
call :list_files "!folder[%%a]!"
)
)
)
goto :menu
:: -------------------------- ---------- ---------- ---------- ---------- ---------- -----
:: LIST FILES
:: -------------------------- ---------- ---------- ---------- ---------- ---------- -----
:list_files
set file=0
for /f "tokens=*" %%a in ('dir /a-d /b "%source%\TXT, Removable0001\%~1\*.txt"') do (
set /a file+=1
set file[!file!]=%%~nxa
)
set /a file+=1
set file[%file%]=Back to Main Menu
:loop
cls
echo -------------------------- ------
echo %~1
echo -------------------------- ------
for /l %%a in (1,1,%file%) do (
echo %%a. !file[%%a]!
)
echo.
set /p selected_file=Enter your selection:
for %%a in (%selected_file%) do (
if "!file[%%a]!"=="" (
echo.
echo Please select from 1..!file!
echo.
pause
) else (
if /i "!file[%%a]!"=="Back to Main Menu" (
exit /b
) else (
notepad "%source%\TXT, Removable0001\%~1\!file[%% a]!"
)
)
)
goto :loop
1. I changed (exit /b) in your script to PAUSE .. for testing purpose ..
2. It searchs all the way down to Z, then Message shown that "Can not find ..."
/////////////////
Searching drive z:...
Cannot find "TXT, Removable0001" folder.
Press any key to continue . . .
==========================
:: TXTMenu
::
:: Written by Paul Tomasi - 11/01/1010
:: ==========================
@echo off
setlocal enabledelayedexpansion
echo.
set /p .=Searching drive <nul
for %%a in (a b d e f g h i j k l m n o p q r s t u v w x y z) do (
set /p .=%%a:...<nul
for /f "tokens=*" %%b in ('dir /ad /b %%a:\ 2^>nul') do (
if /i "%%~nb"=="TXT, Removable0001" (
set source=%%a:
set folder=0
for /f "tokens=*" %%a in ('dir /ad /b /on "!source!\TXT, Removable0001\"') do (
set /a folder+=1
set folder[!folder!]=%%a
)
set /a folder+=1
set folder[!folder!]=Exit
goto :menu
)
)
)
echo.
echo.
echo Cannot find "TXT, Removable0001" folder.
PAUSE ..
::exit /b
:: --------------------------
:: MENU
:: --------------------------
:menu
cls
echo --------------------------
echo MAIN MENU
echo --------------------------
for /l %%a in (1,1,%folder%) do (
echo %%a. !folder[%%a]!
)
echo.
set /p selected_folder=Enter your selection:
for %%a in (%selected_folder%) do (
if "!folder[%%a]!"=="" (
echo.
echo Please select from 1..!folder!
echo.
pause
) else (
if /i "!folder[%%a]!"=="Exit" (
echo.
echo Goodbye.
exit /b
) else (
call :list_files "!folder[%%a]!"
)
)
)
goto :menu
:: --------------------------
:: LIST FILES
:: --------------------------
:list_files
set file=0
for /f "tokens=*" %%a in ('dir /a-d /b "%source%\TXT, Removable0001\%~1\*.txt"')
set /a file+=1
set file[!file!]=%%~nxa
)
set /a file+=1
set file[%file%]=Back to Main Menu
:loop
cls
echo --------------------------
echo %~1
echo --------------------------
for /l %%a in (1,1,%file%) do (
echo %%a. !file[%%a]!
)
echo.
set /p selected_file=Enter your selection:
for %%a in (%selected_file%) do (
if "!file[%%a]!"=="" (
echo.
echo Please select from 1..!file!
echo.
pause
) else (
if /i "!file[%%a]!"=="Back to Main Menu" (
exit /b
) else (
notepad "%source%\TXT, Removable0001\%~1\!file[%%
)
)
)
goto :loop
ASKER
Hi Paul Tomasi,
The folder "TXT, Removable0001" is located at N:\USB, BACKUP, 0001\DOC0001\TXT, Removable0001.
I did not use that folder is because I don't want to mess up with that and that was why I used this folder "My TXT-FILES" as for testing.
And I have tried to search a few folders that are residing in that drive, and the script failed to locate those ..
Thanks
The folder "TXT, Removable0001" is located at N:\USB, BACKUP, 0001\DOC0001\TXT, Removable0001.
I did not use that folder is because I don't want to mess up with that and that was why I used this folder "My TXT-FILES" as for testing.
And I have tried to search a few folders that are residing in that drive, and the script failed to locate those ..
Thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Paul Tomasi,
It works only when I placed the folder in
M:\TXT, Removable0001 (<-- It found it ..)
N:\TXT, Removable0001 (<-- It found it ..)
It would fail if I put it in anywhere like this:
M:\Foler\TXT, Removable0001 (<-- It can not be found)
N:\Directory\TXT, Removable0001 (<-- It can not be found)
Z:\TXT, Removable0001 (<-- It found it ..)
It works only when I placed the folder in
M:\TXT, Removable0001 (<-- It found it ..)
N:\TXT, Removable0001 (<-- It found it ..)
It would fail if I put it in anywhere like this:
M:\Foler\TXT, Removable0001 (<-- It can not be found)
N:\Directory\TXT, Removable0001 (<-- It can not be found)
Z:\TXT, Removable0001 (<-- It found it ..)
ASKER
Hi t0t0,
I am totally sorry for not providing all the information that you needed.
My "TXT, Removable0001" is nested off another folder and another folder and I want the code to search deep into all and any folders for "TXT, Removable0001" that it located.
I have three PCs. (Windows XP, Vista and 7) and never want to put my Data in Drive C:,
External Drives only and those are movable from one PC to another.
I keep testing until I wondered myself that why the searching process runs very fast from Drive A through Drive Z. And I decide to place the "TXT, Removable0001" right at the root of the Drive N, it it found, (Description of Ticket: 26293558).
I am totally sorry for not providing all the information that you needed.
My "TXT, Removable0001" is nested off another folder and another folder and I want the code to search deep into all and any folders for "TXT, Removable0001" that it located.
I have three PCs. (Windows XP, Vista and 7) and never want to put my Data in Drive C:,
External Drives only and those are movable from one PC to another.
I keep testing until I wondered myself that why the searching process runs very fast from Drive A through Drive Z. And I decide to place the "TXT, Removable0001" right at the root of the Drive N, it it found, (Description of Ticket: 26293558).
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi all Experts,
Thanks all the works and the time you guys have spent on this.
Special thanks to t0t0,
Your script works exactly as the way I want, and again I am so sorry for not providing you the information you need.
Thanks all...
Thanks all the works and the time you guys have spent on this.
Special thanks to t0t0,
Your script works exactly as the way I want, and again I am so sorry for not providing you the information you need.
Thanks all...
ASKER
I know Drive A: and Drvive B are no longer existed, but we can assign an External or USB drive into that available drive letters if we use all of others, so I love to have that script to search from Drive (A:) to Drive (Z:).
The "My TXT-FILES Folder" is in (My USB Thumb Drive), of course it won't be in Drive C:\ for my protection.
Thanks