|
You last visited: Today at 16:49
Advertisement
Delete a file with multiple instances and variable path
Discussion on Delete a file with multiple instances and variable path within the AutoIt forum part of the Coders Den category.
04/06/2014, 21:09
|
#1
|
elite*gold: 0
Join Date: Mar 2012
Posts: 380
Received Thanks: 25
|
Delete a file with multiple instances and variable path
OK, so I'd like to make a part of a script that deletes a file called login.swf
typically, a couple of instances of it will exist after LoL patches and the path can vary, like so:
C:\Riot Games\League of Legends\RADS\projects\lol_air_client\releases\0.0. 1.79\deploy\mod\lgn\themes\loginRumbleSupergalaxy
and
C:\Riot Games\League of Legends\RADS\projects\lol_air_client\releases\0.0. 1.79\deploy\mod\lgn\themes\loginVelkoz
Also, the "0.0.1.79" can change depending on the patch, so it would need to be a wildcard.
I understand I need to use the fuction
FileDelete ( "filename" )
but am not sure how to handle multiple instances of the file as well as the varying path structure. Any help would be much appreciated.
|
|
|
04/06/2014, 21:13
|
#2
|
elite*gold: 60
Join Date: Aug 2009
Posts: 2,256
Received Thanks: 815
|
You can get the directories in a folder which you don't know what their name is.
|
|
|
04/06/2014, 21:25
|
#3
|
elite*gold: 0
Join Date: Mar 2012
Posts: 380
Received Thanks: 25
|
Well I can see how that would be good for finding folders, but don't understand how that helps me find and delete my login.swf
Would it be like ? :
#include <File.au3>
_FileListToArray ("C:\Riot Games\League of Legends\RADS\projects\lol_air_client\releases\", login.swf, 1, True)
|
|
|
04/06/2014, 21:56
|
#4
|
elite*gold: 60
Join Date: Aug 2009
Posts: 2,256
Received Thanks: 815
|
Didn't you read my post? If you have looked it up on the help file you'll notice that _FileListToArray also returns folders (if you use the right parameters for it) and you wrote that you have different folder names.
_FileListToArray is to find the varying folders and FileDelete for deleting it after you found the folders with _FileListToArray.
|
|
|
04/06/2014, 21:59
|
#5
|
elite*gold: 27
Join Date: Sep 2009
Posts: 5,592
Received Thanks: 1,596
|
PHP Code:
#include <Array.au3> #include <File.au3> $LeagueOfLegends_BaseDir = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Riot Games\RADS", "LocalRootFolder") if @error Then $LeagueOfLegends_BaseDir = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Riot Games\RADS", "LocalRootFolder") If @error Then MsgBox(16,"ERROR","League of Legends dir not found..") Exit EndIf EndIf $LeagueOfLegends_BaseDir &= "/projects/lol_air_client/releases/" $dirs = _FileListToArray($LeagueOfLegends_BaseDir,"*.*",2) $LeagueOfLegends_BaseDir &= $dirs[1] & "/deploy/mod/lgn/themes/" $dirs2 = _FileListToArray($LeagueOfLegends_BaseDir,"*.*",2) $i = 1 Do FileDelete($LeagueOfLegends_BaseDir & $dirs2[$i] & "/login.swf") $i += 1 Until $i = UBound($dirs2)
|
|
|
04/06/2014, 22:16
|
#6
|
elite*gold: 0
Join Date: Mar 2012
Posts: 380
Received Thanks: 25
|
Quote:
Originally Posted by Paraly
PHP Code:
#include <Array.au3> #include <File.au3> $LeagueOfLegends_BaseDir = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Riot Games\RADS", "LocalRootFolder") if @error Then $LeagueOfLegends_BaseDir = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Riot Games\RADS", "LocalRootFolder") If @error Then MsgBox(16,"ERROR","League of Legends dir not found..") Exit EndIf EndIf $LeagueOfLegends_BaseDir &= "/projects/lol_air_client/releases/" $dirs = _FileListToArray($LeagueOfLegends_BaseDir,"*.*",2) $LeagueOfLegends_BaseDir &= $dirs[1] & "/deploy/mod/lgn/themes/" $dirs2 = _FileListToArray($LeagueOfLegends_BaseDir,"*.*",2) $i = 1 Do FileDelete($LeagueOfLegends_BaseDir & $dirs2[$i] & "/login.swf") $i += 1 Until $i = UBound($dirs2)
|
TYVM, that helps a lot!
|
|
|
04/06/2014, 22:20
|
#7
|
elite*gold: 27
Join Date: Sep 2009
Posts: 5,592
Received Thanks: 1,596
|
Quote:
Originally Posted by turtlebeach
TYVM, that helps a lot!
|
I'm glad I could help, maybe you should try to use the thanks button to say thanks
|
|
|
04/06/2014, 22:42
|
#8
|
elite*gold: 60
Join Date: Aug 2009
Posts: 2,256
Received Thanks: 815
|
Code:
$i = 1
Do
FileDelete($LeagueOfLegends_BaseDir & $dirs2[$i] & "/login.swf")
$i += 1
Until $i = UBound($dirs2)
Really? Why don't you use For-Loops instead?
|
|
|
04/06/2014, 22:58
|
#9
|
elite*gold: 27
Join Date: Sep 2009
Posts: 5,592
Received Thanks: 1,596
|
Quote:
Originally Posted by alpines
Code:
$i = 1
Do
FileDelete($LeagueOfLegends_BaseDir & $dirs2[$i] & "/login.swf")
$i += 1
Until $i = UBound($dirs2)
Really? Why don't you use For-Loops instead?
|
Cause I prefer the Do-Loop?
PHP Code:
For $i = 1 To UBound($dirs2) - 1 FileDelete($LeagueOfLegends_BaseDir & $dirs2[$i] & "/login.swf") Next
who cares..
|
|
|
04/07/2014, 17:38
|
#10
|
elite*gold: 0
Join Date: Dec 2013
Posts: 3
Received Thanks: 0
|
Ha ha ha
Why AutoIt have 3 loop function
I always use For and While but I use Do a little or never :'(
|
|
|
04/07/2014, 18:01
|
#11
|
elite*gold: 95
Join Date: May 2011
Posts: 982
Received Thanks: 189
|
While/For: The expression is tested before the loop is executed so the loop will be executed zero or more times.
Do: The expression is tested after the loop is executed, so the loop will be executed one or more times.
|
|
|
|
Similar Threads
|
Run multiple instances of SWTOR
05/08/2018 - SWTOR Guides & Strategies - 4 Replies
You may have noticed you can't login to 2 launchers or run two copies of the game at the same time. After some research, the only way you can do this is by using ISBoxer/Innerspace and dualboxing on 1 PC. It's easy to do and doesnt use up much resource (it uses a virtualisation engine to run the two instances).
|
Is it possible to run multiple instances of game?
04/12/2012 - 9Dragons - 7 Replies
Hi, i was wondering if its possible to avoid hshield and run few instances of 9dragons, for example to buff yourself, or become disciple of first char?:mofo:
|
Multiple Teamspeak Instances
05/19/2011 - General Coding - 12 Replies
Don't know if this is of any use for you.
I wrote this, because I need to connect to two different TS2 Servers at the Same time. Unfortunately TeamSpeak don't allow us to start multiple Instances, so we can't connect to two Servers...
With this application you actually CAN start multiple "teamspeaks".
Just copy the Executable File into you TeamSpeak Folder and run it. The Teamspeak.exe will start automatically.
---------------------------------------
|
All times are GMT +2. The time now is 16:49.
|
|