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
File Handling
22 posts
• Page 2 of 3 • 1, 2, 3
Re: File Handling
cool ...
Is there a way to RENAME a file [using RUBY] ?
Is there a way to RENAME a file [using RUBY] ?
- RJHollins
- Posts: 1571
- Joined: Thu Mar 08, 2012 7:58 pm
Re: File Handling
Thanks for the LINK. Was having trouble finding the Ruby 1.9.3.
BookMarked
BookMarked
- RJHollins
- Posts: 1571
- Joined: Thu Mar 08, 2012 7:58 pm
Re: File Handling
That's great. Now I just need to study Ruby to find out how to trigger subs with those code lines.
I know how to push strings in and out with "@" I/O, but not yet clear on how to trigger a Ruby sub on demand.
Ah... wait... I think I see. Just replace my modules with a Ruby module and those things will just run.
Great. Off to give it a go.
I know how to push strings in and out with "@" I/O, but not yet clear on how to trigger a Ruby sub on demand.
Ah... wait... I think I see. Just replace my modules with a Ruby module and those things will just run.
Great. Off to give it a go.
- S1User
- Posts: 58
- Joined: Thu Sep 17, 2015 4:05 pm
Re: File Handling
Oh man. I've been working way too hard not using Ruby modules. This below is much cleaner than the rats nest of primitives I had doing the same thing before.
You guys are great.
Schematic: http://i.imgur.com/ynRhihi.png
You guys are great.
Schematic: http://i.imgur.com/ynRhihi.png
- S1User
- Posts: 58
- Joined: Thu Sep 17, 2015 4:05 pm
Re: File Handling
Back to an issue I'm having
It seems FS RUBY does not have the FileUtils class.
What I'm trying to do is:
1. Copy a file to a new dest folder ... then,
2. Re-name the new [copied] file.
3. Insuring that the original file remains intact at original location.
I've used the posted 'File.rename(@old_name, @new_name)' , but it is removing the original file
Note: The goal. I have to make copies of a single file and rename them as new files in a new folder. There could be a dozen or more copies]. I'm using a filename list to increment through in the rename process.
Note 2. I also tried the EXEC primitive to do the copy. I can't seem to get that to work.
I suck
It seems FS RUBY does not have the FileUtils class.
What I'm trying to do is:
1. Copy a file to a new dest folder ... then,
2. Re-name the new [copied] file.
3. Insuring that the original file remains intact at original location.
I've used the posted 'File.rename(@old_name, @new_name)' , but it is removing the original file
Note: The goal. I have to make copies of a single file and rename them as new files in a new folder. There could be a dozen or more copies]. I'm using a filename list to increment through in the rename process.
Note 2. I also tried the EXEC primitive to do the copy. I can't seem to get that to work.
I suck
- RJHollins
- Posts: 1571
- Joined: Thu Mar 08, 2012 7:58 pm
Re: File Handling
Hi,
here a method 4U i got from DWB (hope he don't mind)
Keep on Doing!
Walter
here a method 4U i got from DWB (hope he don't mind)
- Code: Select all
def copy_file(src,dest)
File.open(src, 'rb') do |s|
File.open(dest, 'wb', s.stat.mode) do |f|
IO.copy_stream(s, f)
end
end
end
Keep on Doing!
Walter
-
Walter Sommerfeld - Posts: 249
- Joined: Wed Jul 14, 2010 6:00 pm
- Location: HH - Made in Germany
Re: File Handling
Thanks Walter [....and DWB]
I'll give this a go when I get back.
Appreciate.
I'll give this a go when I get back.
Appreciate.
- RJHollins
- Posts: 1571
- Joined: Thu Mar 08, 2012 7:58 pm
Re: File Handling
hmmm ... no luck getting this code working ... as yet.
- RJHollins
- Posts: 1571
- Joined: Thu Mar 08, 2012 7:58 pm
Re: File Handling
Here u go...
Have Phun
Warning: Dest will be overwritten and path must exist...
Have Phun
Warning: Dest will be overwritten and path must exist...
- Attachments
-
- ...I think U need Admin rights because of ProgFiles path 4 this test schematic:
- copy file fom DWB in ruby (sun mod).png (288.42 KiB) Viewed 18368 times
-
- copy file fom DWB in ruby (sun mod).fsm
- (1.31 KiB) Downloaded 817 times
-
Walter Sommerfeld - Posts: 249
- Joined: Wed Jul 14, 2010 6:00 pm
- Location: HH - Made in Germany
22 posts
• Page 2 of 3 • 1, 2, 3
Who is online
Users browsing this forum: No registered users and 66 guests