View Single Post
Old 07-19-2013, 01:16 PM   #25
Silvuh
quit
Retired StaffFFR Simfile AuthorFFR Music ProducerFFR Veteran
 
Silvuh's Avatar
 
Join Date: Apr 2005
Location: anywhere but here
Posts: 938
Default Re: .sm to .dwi converter

Quote:
Originally Posted by Fission View Post
i'm going to add recursive conversion from a root directory to convert a whole bunch of files at once. that way, everybody can send .sm files to batches instead of having to convert to .dwis
Ohh, I didn't even think about that! Yeah, it would definitely be more convenient to be able to convert all batch files at once than having to make everyone convert their own files before sending them in.

I added the following lines to my script: ("..." is where all the old scripty stuff goes)
Code:
Dir.glob("**").each do |folder|
    next if folder =~ /.*\..{1,2}[^\)]$/
    Dir.chdir(folder)
...
    Dir.chdir("..")
end
These lines makes the old script loop through each folder in the directory ... so it now works for batches if you put the .exe in the song superfolder.

Here's the new executable:
http://www.mediafire.com/download/kk.../batchdwi2.zip

Extra notes: It only searches one directory down. The "next if" line is so the script skips any file with any two- or three-character extension without skipping anything ending with ")" (as all files in the batch should; it won't confuse a file with stepartist "asdfk.as" as not being a directory.) Without this line, the script would break when it tries to enter "batchdwi.exe".

I don't know how to make the executable show a pop-up if it catches something that FFR doesn't support in a file, but that should be something the stepartist should check before sending the file in.

... And I don't know how to search directories and files and stuff in Lua, but here's an explanation of what I did in Ruby in case it helps:
Code:
filearray = Dir.glob("*.{sm,ds,ssc}")
simfile = open(filearray[0]).read()
dwifile = File.new("#{filearray[0].sub(/\..+/, "")}.dwi", 'w')
This Dir.glob expression saves the file name of every .sm, .ds, and .ssc file in the folder into an array. The next line opens the first entry in the array and reads it (so it will read a .ds file if no .sm is present and only read one file). The next line creates the .dwi file, naming it by substituting the file extension of the simfile with nothing and sticking ".dwi" onto it.
__________________

Last edited by Silvuh; 07-26-2013 at 03:53 PM..
Silvuh is offline   Reply With Quote