Use this to open files in Notepad++. I'm using this to edit LUA scripts, but you can edit it for any sort of file, and any program. If the target folder doesn't exist, it will create it and every missing parent folder up to it. It will then create the script files if they don't yet exist and open Notepad++ to edit them.
These command line arguments can be passed.
Useful for quickly hopping out of your editor program to edit an object's script or properties.
Parameters
patha - The left part of the path whose folders should all exist. (ie. "C:\Users\Your Name\Documents\Scripts")
pathb - The right part of the path whose folders may or may not exist.
cl - the command line arguments to pass.
file - the name of the file(s) to make/open. Seperate them with a single space.
w - sets the wait flag in execute file.
notes: As filenames contain the absolute path of the file (because Notepad++'s root isn't the same as the program's root), you probably won't be able to open more than two at a time. In most cases though, one should be fine. (this is assuming there's some sort of limit on the length of the command line string, like 255 characters - correct me if I'm wrong).
To specify the current folder as the root, pass ".\" as patha.
As filenames are seperated with spaces, make sure the file paths don't have spaces inside them.
You'll obviously need Notepad++ otherwise the files will be created but not opened.
Example Here is a .zip containing the program and the dll's you'll need. Extract and run and it will create two files inside two folders.
Note - I left some debug bits in the attached program by mistake - just press a key to step it through.
// Will create (if not yet existing) and then allow editing of a lua script in notepad. Paths must end with a slash.
// patha - "C:\Users\Your Name\Documents\"
// pathb - "Main\SubFolder1\SubFolder2\SubFolder3\etc\"
// file - "MyScript.lua"
FUNCTION LUA_SCRIPT_EDIT(patha as string, pathb as string, cl as string, file as string, w as boolean)
if patha + pathb = "" or file = "" then exitfunction // there must be a path, and at least one file!
if path exist(patha) = 0 then exitfunction // patha is "sure" part of path and must exist.
local tempname as string // declare "running" path/filename, tempname.
if path exist(patha + pathb) = 0 // check if target folder exists.
split string pathb, "\" // split pathb to give each folder.
for n = 1 to split count() - 1 // iterate through each folder.
tempname = tempname + get split word$(n) + "\" // add current folder name to pathc to give folder path.
make directory patha + tempname // create this folder.
next n // next folder will be made inside this one.
endif
patha = patha + pathb // target folder exists now, so get the full path in patha.
local pathc as string // pathc holds the current directory to return to
pathc = get dir$()
set dir patha // set current working folder to the target folder.
pathb = get dir$() + "\" // get absolute path of target folder to give to NP++.
split string file, " " // split file string into each filename.
file = "" // reset file
for n = 1 to split count() // iterate through each filename.
tempname = get split word$(n) // get current filename.
file = file + pathb + tempname + " " // will amass absolute path + filename for each file.
if file exist(tempname) = 0 then make file tempname // create file so you needn't manually in NP++.
next n
execute file "notepad++.exe", cl + " " + file, "C:\Program Files\Notepad++", w // open NP++ to edit your scripts! Wait optional.
set dir pathb // reset current working folder to it's original folder.
ENDFUNCTION
Uncommented version
FUNCTION LUA_SCRIPT_EDIT(patha as string, pathb as string, cl as string, file as string, w as boolean)
if patha + pathb = "" or file = "" then exitfunction
if path exist(patha) = 0 then exitfunction
local tempname as string
if path exist(patha + pathb) = 0
split string pathb, "\"
for n = 1 to split count() - 1
tempname = tempname + get split word$(n) + "\"
make directory patha + tempname
next n
endif
patha = patha + pathb
local pathc as string
pathc = get dir$()
set dir patha
pathb = get dir$() + "\"
split string file, " "
file = ""
for n = 1 to split count()
tempname = get split word$(n)
file = file + pathb + tempname + " "
if file exist(tempname) = 0 then make file tempname
next n
execute file "notepad++.exe", cl + " " + file, "C:\Program Files\Notepad++", w
set dir pathb
ENDFUNCTION
Any queries, tell.
edit: damn thing keeps nicking my backslashes. >_>