Hi there,
I was just wandering if there was a way to test if a folder with a specific name already exist (in a folder like #@#).
It could be using any sort of meter, built-in plugin or lua i don't really mind.
Well actually it could as well use external proggramms (i would prefer to not) or other rainmeter plugin.
So the way i would like to use this is that would like to be able to create a folder with a skin and to see if i can create it.
If a folder with the same name already exists, it would return a certain value so i can use a "if" to say that you can't use this name because a folder is already using it.
If you guys didn't understand something tell me so, i'll try reexplain this.
Edit : Well after some research I found that I can test if a folder exist with a batch file but, to use this with rainmeter (and for what i wan't it to do) i would have to rewrite the batch file and then use a bang using the rainmeter.exe.
Or maybe there is a way to call a batch file with a Variable (so i won't have to rewrite the file anymore) ?
It is currently April 26th, 2024, 7:03 pm
Testing if a folder already exist
-
- Posts: 60
- Joined: November 5th, 2016, 12:15 pm
-
- Rainmeter Sage
- Posts: 16174
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Testing if a folder already exist
It seems the following approach works for me:
- First create a MyLua.lua file, in the #@# folder of your config. Add the following content to it:
Code: Select all
function FolderExists(strFolderName) local fileHandle, strError = io.open(strFolderName.."\\*.*","r") if fileHandle ~= nil then io.close(fileHandle) return true else if string.match(strError,"No such file or directory") then return false else return true end end end function Update() local Folder = SKIN:GetVariable('Folder') if FolderExists(Folder) then SKIN:Bang('!SetVariable', 'Exist', "exists") else SKIN:Bang('!SetVariable', 'Exist', "doesn't exist") end end
- This file will be used by the following skin:
Code: Select all
[Rainmeter] Update=1000 DynamicWindowSize=1 [Variables] Folder=ADD-HERE-THE-PATH-OF-YOUR-FOLDER [MeasureLuaScript] Measure=Script ScriptFile=#@#MyLua.lua [MeterResult] MeasureName=MeasureRun Meter=STRING X=0 Y=0 Padding=15,5,15,5 FontColor=220,220,220 SolidColor=0,0,0,150 FontSize=12 FontFace=Segoe UI StringStyle=BOLD StringAlign=LEFT AntiAlias=1 Text=Folder #Folder# #Exist# DynamicVariables=1