Page 1 of 1

rename file or open a file as the wrong type

Posted: Sat Feb 22, 2020 4:10 am
by TheLegoSensei
So i'm making a little... something? where I can drop in song files meant for Clone Hero and Beat Saber, and it shows a list of the songs and I can play them like an MP3 player, gonna see if I can't do something with the note files and such. but I've got a small hiccup, in that Beat Saber's audio files are ".OGG" renamed into ".EGG". I can of course manually rename the files, but I plan to drop a whole bunch into here, and that would become tedious really fast. is there a command or set of commands that would allow me to rename the file, or open it as an .OGG, ignoring the given file extension? thanks! :awesome:

Re: rename file or open a file as the wrong type

Posted: Sat Feb 22, 2020 4:41 am
by TheLegoSensei
here's how far I've gotten so far:

Code: Select all

renameFile = love.filesystem.read("Songs/" .. SongsDir[menuSelection] .. "/song.egg")
love.filesystem.write(menuSelection .. ".ogg", renameFile)
music = love.audio.newSource(love.filesystem.getSaveDirectory() .. "/" .. menuSelection .. ".ogg", "stream")
but it's not opening the file from the appdata folder. I even had it write the file directory to a .txt, and copied and pasted it into Chrome and it opened the file just fine, so I know for certain the directory is correct, plus the resulting file isn't corrupted in any way. why won't it open?

Re: rename file or open a file as the wrong type

Posted: Sat Feb 22, 2020 4:47 am
by zorg
Hi and welcome to the forums.

First it'd be nice to know what menuSelection and SongsDir[menuSelection] is, because you might be missing the SongsDir[ .. ] part from within newSource's parameter on the third line above.

That said, i think i remember that the current löve version actually tries to see if it can open a file with any decoder it can, so it shouldn't matter if the file extension is egg instead of ogg.

Finally, you don't pass absolute directories to any löve function, they only take the relative paths given by the internal virtual file system, so you'd do one of the following:

Code: Select all

music = love.audio.newSource(menuSelection .. ".egg", "stream")
-- or
music = love.audio.newSource(SongsDir[menuSelection] .. ".egg", "stream")

Re: rename file or open a file as the wrong type

Posted: Sat Feb 22, 2020 5:04 am
by TheLegoSensei
right now when I tell it to play .egg it sounds like lasers
the lasers are really cool, but I don't think it was doing that before...

Re: rename file or open a file as the wrong type

Posted: Sat Feb 22, 2020 5:19 am
by TheLegoSensei
ah, now both .egg play, and sound like lasers (forgot to put math.floor() in several places)

Re: rename file or open a file as the wrong type

Posted: Sat Feb 22, 2020 6:47 am
by TheLegoSensei
OH, I didn't understand what you were telling me, but now I get it

running "love.audio.newSource("song.ogg")" will search both the original zip folder directories as well as the appdata folder directories for the file in question, so I don't need to specify the appdata folder.

that took me a while :oops: thanks for your help!

Re: rename file or open a file as the wrong type

Posted: Sun Mar 29, 2020 7:06 pm
by Smit1h
If you need to change the extension as well, select the entire file name and change it.