Jump to content

Recommended Posts

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <file.au3>

;IniWrite(@WorkingDir & "\Data\Data.ini", "Settings", "ScriptDir", @ScriptDir)
Global $ScriptDir = IniRead(@ScriptDir & "\Data.ini", "Settings", "ScriptDir", "Error")
Global $DataFile = $ScriptDir & "\Data.ini"
MsgBox(0, "", $DataFile)
Global $PlayFile = $ScriptDir & "\Executables\PlayFile.au3"
Global $FileProperties = $ScriptDir & "\Executables\FileProperties.au3"
Global $VideoPlayer = $ScriptDir & "\Executables\VideoPlayer.au3"
MsgBox(0, "", $DataFile)
; Create Folders & install components if they don't exist yet

If FileExists($PlayFile) Then
Else
    ShellExecute($ScriptDir)
    DirCreate($ScriptDir & "\Executables")
    FileInstall($PlayFile, $PlayFile)
EndIf

MsgBox(0, "", "FileExists 1 " & $DataFile)

If FileExists($VideoPlayer) Then
Else
    ShellExecute($ScriptDir)
    DirCreate($ScriptDir & "\Executables")
    FileInstall($VideoPlayer, $DataFile)
EndIf

MsgBox(0, "", "FileExists 2 " & $ScriptDir)

If FileExists($FileProperties) Then
Else
    ShellExecute($ScriptDir)
    DirCreate($ScriptDir & "\Executables")
    FileInstall($FileProperties, $FileProperties)
EndIf

MsgBox(0, "", "FileExists 3 " & $DataFile)


Global $RenameFile = IniRead($DataFile, "Settings", "RenameFile", "False")


; Playlist Name input
Global $playlistnameinput = InputBox("Playlist", "Enter The playlist name", "Name")

Global $playlistCurrentLocation = FileSelectFolder("Specify where the current folder is located", "")

;  Prevent Duplicates
Global $DuplicateCheckArray = IniReadSection($DataFile, "Playlists")
Global $DuplicateCheck = _ArraySearch($DuplicateCheckArray, $playlistnameinput)
If $DuplicateCheck = "-1" Then
Else
    MsgBox(16, "ERROR", "Playlist already exists.")
    Exit
EndIf
MsgBox(0, "", "duplicate check " & $DataFile)

; Playlist Folder Creation
Global $FinalLocation = $ScriptDir & "\Playlists\" & $playlistnameinput
ShellExecute($ScriptDir)
DirCreate($FinalLocation)

Global $PlaylistLength = _FileListToArray($playlistCurrentLocation)
_ArrayDisplay($PlaylistLength)
Global $PlaylistLengthNumber[1][2] = [["Length", $PlaylistLength[0]]]
If $RenameFile = "True" Then
    For $i = 0 To $PlaylistLength[0]
        $filetype = StringSplit($PlaylistLength[$i], ".")
        FileMove($playlistCurrentLocation & "\" & $PlaylistLength[$i], $FinalLocation & "\" & $playlistnameinput & " " & $i & "." & $filetype[2])
        _ArrayAdd($PlaylistLengthNumber[$i], $i & "|" & $playlistnameinput & " " & $i)
        ;FileMove($playlistCurrentLocation & "\" & $PlaylistMp4[$i], $FinalLocation)
        ;FileMove($playlistCurrentLocation & "\" & $PlaylistMkv[$i], $FinalLocation)
        ;FileMove($playlistCurrentLocation & "\" & $playlistSrt[$i], $FinalLocation)
        ;FileMove($playlistCurrentLocation & "\" & $PlaylistVlc[$i], $FinalLocation)
    Next
ElseIf $RenameFile = "False" Then
    For $i = 1 To $PlaylistLength[0]
        $filetype = StringSplit($PlaylistLength[$i], ".")
        FileMove($playlistCurrentLocation & "\" & $PlaylistLength[$i], $FinalLocation)
        _ArrayAdd($PlaylistLengthNumber[$i], $i & "|" & $PlaylistLength[$i])
    Next
EndIf
MsgBox(0, "", "FileMove " & $DataFile)

; General Data File
$Total = IniRead($DataFile, "Playlists", "Total", "Error") + 1
IniWriteSection($DataFile, $playlistnameinput, "Key" & $Total & @LF & "PlaylistLength" & $PlaylistLength[0] & @LF & "CurrentEpisode=1" & @LF & "TimeWatched=00:00:00" & @LF & "VideoDuration=00:00:00")
IniWriteSection($DataFile, $playlistnameinput & "Episodes", $PlaylistLength)
IniWrite($DataFile, "Playlists", "SelectedPlaylist", $Total)
IniWrite($DataFile, "Playlists", "Total", $Total)
IniWrite($DataFile, "Playlists", $Total, $playlistnameinput)
MsgBox(0, "", "Filewrite " & $DataFile)

Could anyone inform me why IniWrite would work only at the very start of the script but nowhere else? i've tried looking online but what i found didn't really apply as far as i'm aware

So far the File "Data.ini" only contains this:

[Settings]
ScriptDir=C:\Users\onbek\OneDrive\Documenten\autoItScripts\PlaylistTracker 2

 

Edited by WhaleJesus
Link to post
Share on other sites
  • Developers
Posted (edited)

I guess the content of variable

$ScriptDir

is wrong...  just check that first... and why not use 

ScriptDir & "\Data.ini"

Like with iniread()?

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites
Posted (edited)
10 minutes ago, Jos said:

I guess the content of variable



$ScriptDir

is wrong...  just check that first... and why not use 



ScriptDir & "\DaData.in"

Like with iniread()?

 

When i was searching online i read that @scriptdir could be changed by some statements so i tried storing it in a variable, The location stored in "Settings" is absolutely correct though

IniWrite gets ignored - AutoIt General Help and Support - AutoIt Forums (autoitscript.com)

9 minutes ago, Danp2 said:

Hard to know for sure without more details. The only place that you write that value to the ini file is the top line that's commented out. Have you ruled out the possibility that your subsequent updates are being written to a different file?

 

Yeah, i checked the parent and subfolders, can't find an ini file anywhere else

 

 

Edited by WhaleJesus
Link to post
Share on other sites
6 minutes ago, WhaleJesus said:

When i was searching online i read that @scriptdir could be changed by some statements so i tried storing it in a variable, The location stored in "Settings" is absolutely correct though

Some operations change the WorkingDir, but the macro @ScriptDir remains as it is.

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to post
Share on other sites
  • Developers

@workdir can change but @ScriptDir will not change so just use that as your current code isn't saving it properly.

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to post
Share on other sites
11 minutes ago, JockoDundee said:

@WhaleJesus, congratulations on being credited with your third solution in just as many discussions!

Thank you Jocko, for this contribution. I was thinking exactly the same, but didn't want to get into the center of a potential shitstorm by writing something about it myself :lol:.

@WhaleJesus :

One major aspect behind the feature of marking a post as "Solution" is to make it easier for other users to find it (especially in extensive threads).

3 hours ago, WhaleJesus said:

Found out something is going wrong in the for loop, the ini file isn't being written to because the script isn't getting there

This is not a solution, but only describes that you have recognized your problem ;).

35 minutes ago, WhaleJesus said:

lol sorry i'll delete the post didn't know it mattered

You don't have to delete your post, just remove the 'solved' tag.

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to post
Share on other sites
7 minutes ago, Musashi said:

Thank you Jocko, for this contribution. I was thinking exactly the same, but didn't want to get into the center of a potential shitstorm by writing something about it myself :lol:.

@WhaleJesus :

One major aspect behind the feature of marking a post as "Solution" is to make it easier for other users to find it (especially in extensive threads).

This is not a solution, but only describes that you have recognized your problem ;).

You don't have to delete your post, just remove the 'solved' tag.

Don't worry i don't like drama, thanks for the explanation! Probably obvious enough that i should've figured it out myself but i'm sleep deprived half of the time

Link to post
Share on other sites
19 minutes ago, WhaleJesus said:

Don't worry i don't like drama, thanks for the explanation!

No problem, you are not the only one for whom this "new brilliant feature" causes some confusion :lol:.

Edit : I just noticed that you marked @JockoDundee 's solution in the thread loop hotkey file . This was certainly the right choice 👍.

Edited by Musashi

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to post
Share on other sites
4 hours ago, WhaleJesus said:

lol sorry i'll delete the post didn't know it mattered

It matters to some people.

Anybody that answers questions with custom code must have a reason for the effort:

Some may do it for the likes,

Some say they do it for the thanks,

Some claim they do it as a personal challenge, and

Some will tell you they do it just to help out someone in need.

But I say many do it to be judged on their solution amongst their peers.

This explains why a desperate sounding post regarding Send() or WinActive() might languish for days with just a few replies, yet a tasty  RegEx problem will get 10 replies in the first hour :)

Code hard, but don’t hard code...

Link to post
Share on other sites
5 hours ago, JockoDundee said:

It matters to some people.

Anybody that answers questions with custom code must have a reason for the effort:

Some may do it for the likes,

Some say they do it for the thanks,

Some claim they do it as a personal challenge, and

Some will tell you they do it just to help out someone in need.

But I say many do it to be judged on their solution amongst their peers.

This explains why a desperate sounding post regarding Send() or WinActive() might languish for days with just a few replies, yet a tasty  RegEx problem will get 10 replies in the first hour :)

That can also be pretty effective for newbies like me, it's always better to figure something out yourself than have the answer handed to you, but it can be so so frustrating when you just can't seem to figure it out

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...