Diamond
Joined: 31 Mar 2006 Posts: 127 Location: New York
|
Posted: Sun Aug 31, 2008 2:44 pm Post subject: Script to turn folders into menus |
|
|
Here's a script that turns folders into menus. I know this has already been done, but what the hell. This variation is a bit unorthodox, but it works. Just pass the folder to the script as a command line parameter and make sure to enclose it in quotes if it contains spaces. If you run it without parameters, it works on the folder containing the script. Holding down the Shift key while selecting a file will ask if you want to delete it. It's very basic, but I probably won't be improving it very much since it already does most of what I want. If anyone else cares enough to work on it feel free. It would be nice if I could figure out how to remove file extensions, but I suspect that would be somewhat difficult using this approach.
| Code: | #NoTrayIcon
#SingleInstance Ignore
SetBatchLines -1
Folder = %1%
If 1 =
Folder = %A_ScriptDir%
Loop %Folder%\*.*, 2, 1
{
SubDir = %A_LoopFileDir%\%A_LoopFileName%
Menu %SubDir%, Add
Menu %SubDir%, DeleteAll
Menu %A_LoopFileDir%, Add, %A_LoopFileName%, :%SubDir%
}
Loop %Folder%\*.*,, 1
Menu %A_LoopFileDir%, Add, %A_LoopFileName%, Run
Menu %Folder%, Show
Return
Run:
GetKeyState ShiftState, Shift
If ShiftState = D
{
MsgBox 4, Confirm File Delete, Are you sure you want to delete '%A_ThisMenuItem%'?
IfMsgBox Yes
FileDelete %A_ThisMenu%\%A_ThisMenuItem%
}
Else
Run %A_ThisMenu%\%A_ThisMenuItem%
ExitApp |
|
|