- Download a folder full of files to your Linux machine with wget
- How to make a nice DOS-styled menu with Bash scripting
Download a folder full of files to your Linux machine with wget
Downloading a folder with wget can be quite hard sometimes, I had issues with the download stalling. But this solution does work very well.
┌──(john㉿DESKTOP-PF01IEE)-[~/Documents/phothm] └─$ wget -e robots=off --cut-dirs=3 --user-agent=Mozilla/5.0 --reject="index.html*" --no-parent --recursive --relative --level=1 --timeout=5 --no-directories http://www.tro.moph.go.th/data/clip_new/view3/ |
This works very well to download a lot of files at once.
I managed to download this clipart very easily, this is old clipart from Microsoft Office `95.
┌──(john㉿DESKTOP-PF01IEE)-[~/Documents/phothm] └─$ ls 'index.html?C=D;O=A.tmp' j0083934.wmf j0088188.wmf j0123237.wmf j0144305.jpg j0144393.jpg j0145016.jpg j0145060.jpg j0145093.jpg j0145123.jpg j0145175.jpg j0145265.jpg j0145331.jpg j0145354.jpg j0148918.jpg j0154830.wmf PH01189J.jpg.1 PH01310J.jpg PH02289J.jpg 'index.html?C=S;O=A.tmp' j0083948.wmf j0088190.wmf j0123241.wmf j0144349.jpg j0144396.jpg j0145025.jpg j0145062.jpg j0145104.jpg j0145126.jpg j0145187.jpg j0145281.jpg j0145332.jpg j0145355.jpg j0148920.jpg j0177645.jpg PH01190J.jpg PH01366J.jpg PH02296J.jpg j0078609.jpg j0083954.wmf j0089474.wmf j0123243.wmf j0144351.jpg j0144397.jpg j0145032.jpg j0145063.jpg j0145105.jpg j0145127.jpg j0145188.jpg j0145296.jpg j0145333.jpg j0145356.jpg j0148947.jpg j0181469.jpg PH01190J.jpg.1 PH01375J.jpg PH02315J.jpg j0079204.wmf j0083966.wmf j0100770.wmf j0123245.wmf j0144352.jpg j0144398.jpg j0145033.jpg j0145067.jpg j0145108.jpg j0145129.jpg j0145191.jpg j0145301.jpg j0145336.jpg j0145378.jpg j0148953.jpg j0182119.jpg PH01198J.jpg PH01381J.jpg PH02316J.jpg j0079206.wmf j0083972.wmf j0100802.wmf j0123247.wmf j0144357.jpg j0144399.jpg j0145034.jpg j0145068.jpg j0145110.jpg j0145130.jpg j0145196.jpg j0145302.jpg j0145338.jpg j0145379.jpg j0148954.jpg j0182183.jpg PH01198J.jpg.1 PH01385J.jpg PH02366J.jpg j0083874.wmf j0083974.wmf j0100968.wmf j0123249.wmf j0144380.jpg j0144400.jpg j0145044.jpg j0145069.jpg j0145111.jpg j0145131.jpg j0145204.jpg j0145315.jpg j0145344.jpg j0145385.jpg j0149245.jpg j0182325.jpg PH01206J.jpg PH01386J.jpg PH02524J.jpg j0083878.wmf j0083988.wmf j0109299.wmf j0123251.wmf j0144383.jpg j0144401.jpg j0145045.jpg j0145070.jpg j0145114.jpg j0145150.jpg j0145213.jpg j0145316.jpg j0145345.jpg j0145471.jpg j0149259.jpg j0192131.wmf PH01206J.jpg.1 PH02102J.jpg PH02949J.jpg j0083884.wmf j0083992.wmf j0122767.wmf j0142157.wmf j0144385.jpg j0144402.jpg j0145047.jpg j0145071.jpg j0145115.jpg j0145151.jpg j0145244.jpg j0145317.jpg j0145347.jpg j0148788.jpg j0149261.jpg j0227689.jpg PH01207J.jpg PH02104J.jpg WS_FTP.LOG j0083892.wmf j0084050.wmf j0122905.wmf j0142227.wmf j0144386.jpg j0144453.jpg j0145051.jpg j0145078.jpg j0145116.jpg j0145152.jpg j0145255.jpg j0145321.jpg j0145349.jpg j0148810.jpg j0149270.jpg j0230919.wmf PH01207J.jpg.1 PH02146J.jpg j0083900.wmf j0084062.wmf j0122967.wmf j0144247.jpg j0144387.jpg j0144459.jpg j0145053.jpg j0145087.jpg j0145118.jpg j0145153.jpg j0145257.jpg j0145323.jpg j0145350.jpg j0148837.jpg j0149280.jpg PH01178J.jpg PH01232J.jpg PH02168J.jpg j0083920.wmf j0088072.wmf j0122979.wmf j0144248.jpg j0144389.jpg j0144466.jpg j0145054.jpg j0145091.jpg j0145120.jpg j0145162.jpg j0145261.jpg j0145324.jpg j0145351.jpg j0148849.jpg j0149290.jpg PH01178J.jpg.1 PH01253J.jpg PH02169J.jpg j0083922.wmf j0088074.wmf j0123089.wmf j0144269.jpg j0144392.jpg j0144469.jpg j0145055.jpg j0145092.jpg j0145121.jpg j0145164.jpg j0145262.jpg j0145327.jpg j0145352.jpg j0148858.jpg j0150335.wmf PH01189J.jpg PH01297J.jpg PH02248J.jpg |
So, this is a very good solution to mirror an online file download directory.

How to make a nice DOS-styled menu with Bash scripting
#!/bin/bash # Display menu options to the user while true; do echo "======= Main Menu =======" echo "1. Option 1" echo "2. Option 2" echo "3. Option 3" echo "4. Quit" echo -n "Enter your selection [1-4]: " # Read user's selection read choice # Respond to user's selection case $choice in 1) echo "You selected Option 1.";; 2) echo "You selected Option 2.";; 3) echo "You selected Option 3.";; 4) break;; *) echo "Invalid selection.";; esac echo done |
This script displays the menu options to the user, reads their selection, and responds to their selection using a case
statement. The break
statement is used to exit the loop and end the script when the user selects the “Quit” option. The *
case is used to handle any invalid selections.