If you have a problem or need to report a bug please email : support@dsprobotics.com
There are 3 sections to this support area:
DOWNLOADS: access to product manuals, support files and drivers
HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects
USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here
NEW REGISTRATIONS - please contact us if you wish to register on the forum
Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright
Using Ruby for advanced saving tasks
12 posts
• Page 1 of 2 • 1, 2
Using Ruby for advanced saving tasks
Hi,
Just wondered if Ruby can make any advanced file saving tasks in a quick and elegant way. My challenge is like that:
I want to save the same text file to any sub-folder that is seeded in the highest folder in the hierarchy I pre-determine. For example:
The highest I determine is "c:\documents\flowstone". This folder contains 3 sub-folders named "instruments", "effects", "midi tools". Now, when I save a file, I want a copy of it in each of the sub-folders. The challenge here then is that if the user adds some more folders of his own to "c:\documents\flowstone\", the code would still be able recognizing the new folders as sub-folders and save the file into them. So It should be looking like this:
"c:\documents\flowstone\instruments\preset 1.txt"
"c:\documents\flowstone\effects\preset 1.txt"
"c:\documents\flowstone\miditools\preset 1.txt"
The user added the sub-folder "samples" -> the code recognizes it as well and save the file into it too:
"c:\documents\flowstone\samples\preset 1.txt"
Doable?
Just wondered if Ruby can make any advanced file saving tasks in a quick and elegant way. My challenge is like that:
I want to save the same text file to any sub-folder that is seeded in the highest folder in the hierarchy I pre-determine. For example:
The highest I determine is "c:\documents\flowstone". This folder contains 3 sub-folders named "instruments", "effects", "midi tools". Now, when I save a file, I want a copy of it in each of the sub-folders. The challenge here then is that if the user adds some more folders of his own to "c:\documents\flowstone\", the code would still be able recognizing the new folders as sub-folders and save the file into them. So It should be looking like this:
"c:\documents\flowstone\instruments\preset 1.txt"
"c:\documents\flowstone\effects\preset 1.txt"
"c:\documents\flowstone\miditools\preset 1.txt"
The user added the sub-folder "samples" -> the code recognizes it as well and save the file into it too:
"c:\documents\flowstone\samples\preset 1.txt"
Doable?
-
kortezzzz - Posts: 763
- Joined: Tue Mar 19, 2013 4:21 pm
Re: Using Ruby for advanced saving tasks
Hi,
maybe this could help:
found here: https://stackoverflow.com/questions/800189/get-immediate-subdirectories-in-ruby
maybe this could help:
If you mean to find all the immediate subdirectories (just one level below where you are), try this:
Dir.chdir("/some/path/you/want/to/check/below")
subdir_list=Dir["*"].reject{|o| not File.directory?(o)}
That is: change directory someplace, construct an array of files found there, reject those array elements that aren't directories, and return the resulting culled arrray.
found here: https://stackoverflow.com/questions/800189/get-immediate-subdirectories-in-ruby
-
Walter Sommerfeld - Posts: 249
- Joined: Wed Jul 14, 2010 6:00 pm
- Location: HH - Made in Germany
Re: Using Ruby for advanced saving tasks
kortezzz,
what exactly is the concept behind this. I currently don't understand why you would want to save the very same file 3, 5 or 10 times?
Also, is it an executable or a plugin?
And finally, I would not recommend to let Ruby continuously watch a directory just in case a new folder is being created. This "update" should be initiated manually to not waste CPU.
But I might be able to say more, after your answers.
what exactly is the concept behind this. I currently don't understand why you would want to save the very same file 3, 5 or 10 times?
Also, is it an executable or a plugin?
And finally, I would not recommend to let Ruby continuously watch a directory just in case a new folder is being created. This "update" should be initiated manually to not waste CPU.
But I might be able to say more, after your answers.
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: Using Ruby for advanced saving tasks
Thank you, walter! It does helps
Maybe it won't do the whole requested process, but it does the sub-directories finding which lets me do the rest with greens
Attached the schematic for anyone that might get interested in this. Thanks!
Tula,
I need it as an ad hoc solution for a guy which I've created 5 standalone apps for him, each with it's own GUI resizing feature which it's size gets saved to a file once it get changed. The apps are somewhat the same size and used for presentations he makes and get carried on a USB disk on key. Wherever he arrives for a presentation, he uses the local computer (connected to a projector) to mirror the screen on the wall. Sometimes it's a desktop. Sometimes a laptop. And as we know, FS apps shown differ on each platform.
What he needs is a simple fast solution that resizes them all on the fly so before they get opened, so he won't need to resize each one of them manually and spend time. So I'm creating for him a small exe app which changes all the sizes on the fly by using a single button click. Once the sizes get determined by the the exe app, they will all open at the same size. That's why I need to look at his the sub-folders. I don't think it would be somehow harmful, doesn't it?
Maybe it won't do the whole requested process, but it does the sub-directories finding which lets me do the rest with greens
Attached the schematic for anyone that might get interested in this. Thanks!
Tula,
I need it as an ad hoc solution for a guy which I've created 5 standalone apps for him, each with it's own GUI resizing feature which it's size gets saved to a file once it get changed. The apps are somewhat the same size and used for presentations he makes and get carried on a USB disk on key. Wherever he arrives for a presentation, he uses the local computer (connected to a projector) to mirror the screen on the wall. Sometimes it's a desktop. Sometimes a laptop. And as we know, FS apps shown differ on each platform.
What he needs is a simple fast solution that resizes them all on the fly so before they get opened, so he won't need to resize each one of them manually and spend time. So I'm creating for him a small exe app which changes all the sizes on the fly by using a single button click. Once the sizes get determined by the the exe app, they will all open at the same size. That's why I need to look at his the sub-folders. I don't think it would be somehow harmful, doesn't it?
- Attachments
-
- (find sub directories).fsm
- (1.12 KiB) Downloaded 967 times
-
kortezzzz - Posts: 763
- Joined: Tue Mar 19, 2013 4:21 pm
Re: Using Ruby for advanced saving tasks
.
Last edited by MichaelBenjamin on Mon Sep 21, 2020 11:00 am, edited 1 time in total.
- MichaelBenjamin
- Posts: 275
- Joined: Tue Jul 13, 2010 1:32 pm
Re: Using Ruby for advanced saving tasks
Yep, Michael. This powerful and useful aspect of Ruby was barely touched or discussed. There were few great examples over the years how to make use of Ruby for that (some of them requested by me) and I use those small patches in my projects until today. Maybe we should make a dedicated post for that, if people are interested. I see that quite many forum members downloaded my very simple schematic, which definitely proves that there is an interest from the "silent masses" which would never ask anything but wait for someone else to post.
-
kortezzzz - Posts: 763
- Joined: Tue Mar 19, 2013 4:21 pm
Re: Using Ruby for advanced saving tasks
I've done a complete folder reading tool, that reads in a list of the names of any file in a folder and stores the path for later access. I made it public some years ago. Didn't get many downloads and so far (as I'm aware of) Spogg is the only one who made actually use of it (to access files from a dropdown in his sample based plugins).
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: Using Ruby for advanced saving tasks
Tula, Well, the reason might be that most people don't understand what too complex tools do. I think they would try something more simple that can be easily detected with a schematic. Dunno if you did it, but I bet there would have have been much more downloads if you were demonstrating each feature there with a schematic. I also bet that most of the "silent masses" members pass or read at a glance anything that sounds to their ears like "bla bla bla" (I mean anything that most of them don't understand or don't wanna understand) without anything to download.
-
kortezzzz - Posts: 763
- Joined: Tue Mar 19, 2013 4:21 pm
Re: Using Ruby for advanced saving tasks
It was (and still is, buried somewhere in "examples") a complete tool, ready to use in any app/plugin. Spogg did so. You just needed to enter the start folder, the rest is just clicking on a dropdown menu to select a file, and if people are not even able to do that, I don't think they can handle ANY tool given to them.
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: Using Ruby for advanced saving tasks
Strange, but looks like I'd never encountered such a tool (because If I had, it probably was in my tool box and would never forget about it). Any chance you at least remember how it called so we can run a search on the "examples" to find it?
-
kortezzzz - Posts: 763
- Joined: Tue Mar 19, 2013 4:21 pm
12 posts
• Page 1 of 2 • 1, 2
Who is online
Users browsing this forum: Google [Bot] and 70 guests