Renaming a file on C:\ with a switch knob

For general discussion related FlowStone
Post Reply
Mr. Mac Snoer
Posts: 17
Joined: Sun Nov 08, 2015 1:05 am

Renaming a file on C:\ with a switch knob

Post by Mr. Mac Snoer »

Lets say I have a file "a.txt" on my c:\.
When I turn the switch to "true" in the gui I want to rename "C:\a.txt" to "c:\xyz_a.txt".
When I turn the switch to "false" in the gui I want to rename the file back to "c:\a.txt".

Any hints would be appreciated. :)
Mr. Mac Snoer
Posts: 17
Joined: Sun Nov 08, 2015 1:05 am

Re: Renaming a file on C:\ with a switch knob

Post by Mr. Mac Snoer »

Code: Select all

File.rename("old_name", "new_name")

should work... :)

..now I just need to connect this to a switch
Mr. Mac Snoer
Posts: 17
Joined: Sun Nov 08, 2015 1:05 am

Re: Renaming a file on C:\ with a switch knob

Post by Mr. Mac Snoer »

Here is another simple solution with Ruby Shoes.

The folder is C:\Test\, the file is called A.txt and will be renamed to INACTIVE_A.txt with button one and back to A.txt with button two.

Code: Select all

Shoes.app do
  stack do
    button "Rename A.txt to INACTIVE_A.txt" do
      Dir.chdir("C:/Test")
      File.rename("A.txt", "INACTIVE_A.txt")
    end
    button "Rename INACTIVE_A.txt to A.txt" do
      Dir.chdir("C:/Test")
      File.rename("INACTIVE_A.txt", "A.txt")
    end 
  end


I will try with Flowstone. :)
Post Reply