ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Forgetting the language difficulties of batch for Windows and what syntax it has now, there's a functional requirement which isn't too easy here, or too clearly written, or shall we say reasonably written.
You wish to find all files that are of a certain type and then randomize the selection of them.
OK, maybe not so bad, and maybe something which can be done in memory versus the brute force I'd use, a file.
I.e. if I had to find all MP3 files, I'd do a find command for that extension. I'd save that into a file. And then I'd figure out how to either randomize the lines of that file, or randomize my picking of any one given line from that file. I suppose I'd do the second option.
Sorry I'd have to work a bit to determine for myself how to do that in bash or C. I'm no longer versed in batch language. (Since autoexec.bat went away)
A more important point though is that you need to clarify your pseudocode and select the tasks which you are going to perform to accomplish this.
Or at least you need to understand that somehow you have to find a list of all files and where they are.
I seriously doubt in any system Linux or Windows that you say some element of the directory tree structure can be treated as "random". I think you have to find all that can be found, or a bunch of them, and then find a way to randomize the final selection from that list.
Don't think collage is something I could do ATM - It would be helpful to have others & someone to annoy.
you're right though computers are a very strange and addicting place to explore (electric traffic)
Ok so I'll keep learning DOS (most PC's i fix are Windows) continue messing around with linux distros and move to something like Python. Whould Python be a good all rounder ?
Heard alot of people talk about Python & Perl. Will leave that as a last question otherwise You'll be here all day (many many questions)
"I seriously doubt in any system Linux or Windows that you say some element of the directory tree structure can be treated as "random". I think you have to find all that can be found, or a bunch of them, and then find a way to randomize the final selection from that list"
sorry didn't see the 2ed page till now.
Think I need to sit, chill and tinker. Was just a thought of how to get past unknown variables (network cards, random file names)
From what you guys are saying sounds like computers only work with absolutes or it takes time to bodge something together ?
Anyway thank you for putting up with the clueless\newbie questions guys
Last edited by trainspotting; 04-25-2018 at 03:01 AM.
I thought BASH was the standard scripting environment for Windows now?
It isn't. Windows Subsystem for Linux is a separate world that doesn't come out of box and has too many limitations. Older third-party stuff such as Cygwin and MSYS2 has same problems. BASH is too tied to UNIX-like systems.
Advanced scripting on Windows is done via PowerShell for years, or via third-party stuff such as AutoHotkey; before PowerShell there was active usage of VBScript/JScript. However, BAT/CMD still remains widely used for simple tasks as PowerShell is a bit heavyweight and complicated.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.