cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar

Renaming or deleting a folder from within JSL

The answer to this question is almost certainly related to another one I posed a while back (http://communities.sas.com/message/110494#110494), but this one probably warrants a new thread: is it possible to rename or delete a folder using JSL?  The earlier thread contains a script contributed by MattF showing how a file can be renamed or deleted, but I now find that I need to delete not only the file itself but the folder containing it.  Can that be done?  (I've tried using the same script but simply substituting the name of the folder instead of the file name, but that doesn't seem to work - unless I've made an error, which I don't think I have - and I can't see any command that looks as though it might perform that task at http://msdn.microsoft.com/en-us/library/aa365239(VS.85).aspx).

On a related point, is it possible to get a list of all the tasks that can be performed using the object called "kernel32" in the earlier script?

Many thanks,

David

1 ACCEPTED SOLUTION

Accepted Solutions
jschroedl
Staff

Renaming or deleting a folder from within JSL

As of JMP 9, you can use JSL to create and delete directories directly. It didn't make it into the scripting index unfortunately.

Create Directory("c:\temp2");

Delete Directory("c:\temp2");

Also, just for completeness, the kernel32 object mentioned in the post by MattF refers to functions he's explicitly defining in JSL whichmap to features exposed from DLLs in the OS from the file kernel32.dll.  

The Microsoft Developer Network web site documents the functions available (http://msdn.microsoft.com/en-us/library/windows/desktop/aa363915(v=vs.85).aspx) from Windows itself but you need to translate the parameters into the JSL definitions so a bit of programming knowhow is required.

There is an API for deleting a folder/directory called RemoveDirectory: http://msdn.microsoft.com/en-us/library/windows/desktop/aa365488(v=vs.85).aspx but the caveat here is that the directory must be empty.  There is another more advanced funciton to recursively delete the files and directories called SHFileOperation() but it looks like a beast to create the appropriate JSL.

John

View solution in original post

2 REPLIES 2
jschroedl
Staff

Renaming or deleting a folder from within JSL

As of JMP 9, you can use JSL to create and delete directories directly. It didn't make it into the scripting index unfortunately.

Create Directory("c:\temp2");

Delete Directory("c:\temp2");

Also, just for completeness, the kernel32 object mentioned in the post by MattF refers to functions he's explicitly defining in JSL whichmap to features exposed from DLLs in the OS from the file kernel32.dll.  

The Microsoft Developer Network web site documents the functions available (http://msdn.microsoft.com/en-us/library/windows/desktop/aa363915(v=vs.85).aspx) from Windows itself but you need to translate the parameters into the JSL definitions so a bit of programming knowhow is required.

There is an API for deleting a folder/directory called RemoveDirectory: http://msdn.microsoft.com/en-us/library/windows/desktop/aa365488(v=vs.85).aspx but the caveat here is that the directory must be empty.  There is another more advanced funciton to recursively delete the files and directories called SHFileOperation() but it looks like a beast to create the appropriate JSL.

John

Renaming or deleting a folder from within JSL

Perfect - that looks just what I need!  Many thanks.