DonationCoder.com Software > Post New Requests Here
IDEA: Create a containing folder by right clicking on a file
ak_:
Done :) Here is FileNanny 1.3.1 (version number kinda randomly chosen) : [not available]
Changelog :
- if the folder already exists, FileNanny uses it instead of acting lunatic (that's an improvement, isn't it ?).
- added a FileNanny.nfo info file
Source code (as usual, really messy and obscure, even for me) :
--- ---;; FileNanny
;; version 1.3.1
;; "Go to your room !"
;; by ak
#SingleInstance ignore
iniFile = %A_ScriptDir%\FileNanny.ini
if 0 = 0
{
gosub CreateGUI
gosub checkboxes
}
else
{
Iniread shiftKey, %iniFile%, options, shiftKey
Iniread similar, %iniFile%, options, similarfiles
GetKeyState kstate, Shift
if (shiftKey = 1 and kstate = "D")
editFolder = 1
if (shiftKey = 0 and kstate = "U")
editfolder = 1
Loop, %0%
{
param := %A_Index%
SplitPath param, fileName, dirName, extension, fileNameNoExt
rawName = %fileNameNoExt%
gosub convert
if editFolder = 1
{
InputBox InputRawName, FileNanny, Name of the folder to create, , 320, 120, , , , , %rawName%
rawName = %InputRawName%
if ErrorLevel
ExitApp
}
dirToCreate = %dirName%\%rawName%
IfNotExist, %dirToCreate%
FileCreateDir %dirToCreate%.FileNanny
IfExist, %dirToCreate%
FileMoveDir %dirToCreate%, %dirToCreate%.FileNanny, 1
fileNewName = %rawName%.%extension%
FileMove %param%, %dirToCreate%.FileNanny\%fileNewName%
;; Similar files detection
if (similar = 1)
{
Loop %dirName%\*.*
{
Splitpath A_LoopFilename, , , ,similarNoExt
if (similarNoExt = rawName)
{
FileMove %dirName%\%A_LoopFilename%, %dirToCreate%.FileNanny\%A_LoopFilename%
}
}
}
;;
FileMoveDir %dirToCreate%.FileNanny, %dirToCreate%, 1
}
ExitApp
}
return
CreateGUI:
gui destroy
RegRead, regTest, HKEY_CLASSES_ROOT, *\shell\FileNanny
if strlen(regTest) = 0
{
button1Text = Add context menu item
button1Action = addCMI
}
else
{
button1Text = Remove context menu item
button1Action = remCMI
}
sendToFolder = %UserProfile%\SendTo
ifnotExist %sendToFolder%\filenanny.lnk
{
button2text = Add 'Send to' shortcut
button2action = addST
}
else
{
button2text = Remove 'Send to' shortcut
button2action = remST
}
Gui, Add, Button, x126 y225 w70 h30 gQuit, Quit
Gui, Add, Tab, x3 y5 w315 h260 vSelectedTab, Configuration|Options
Gui, Font, s9 w600
Gui tab, Configuration
Gui font, norm
Gui, Add, Button, x90 y65 w140 h30 g%button1Action% vCMIb, %button1Text%
Gui, Add, Button, x90 y125 w140 h30 g%button2Action% vSTb, %button2Text%
Gui tab, Options
if strlen(regTest) = 0
{
regTest = n/a
disabledOrNot = disabled
}
Gui, Add, text, x26 y59 w190 h20 vCurrentCMI, Current : %regTest%
Gui, Add, Button, x226 y55 w70 h20 %disabledOrNot% gchangeCMI vCMIc, Change
Gui, Add, GroupBox, x16 y35 w290 h50 , Context menu text
Gui, Add, CheckBox, x16 y95 w300 h30 vshiftKey gini, Holding the Shift key is required to modify `nfolder name before its creation
Gui, Add, GroupBox, x16 y135 w290 h50 , Convert these to spaces
Gui, Add, CheckBox, x30 y150 w50 h30 vconvDot gini, .
Gui, Add, CheckBox, x80 y150 w50 h30 vconvMinus gini, -
Gui, Add, CheckBox, x130 y150 w50 h30 vconvUnderscore gini, _
Gui, Add, CheckBox, x180 y150 w50 h30 vconvPercent gini, `%20
Gui, Add, CheckBox, x16 y195 w300 h30 vsimilar gini, Move similar files
Gui, Show, h270 w320, FileNanny
return
ini:
Gui submit, NoHide
Iniwrite %shiftKey%, %iniFile%, options, shiftkey
Iniwrite %convDot%, %iniFile%, convert, dots
Iniwrite %convMinus%, %iniFile%, convert, minus
Iniwrite %convUnderscore%, %iniFile%, convert, underscore
Iniwrite %convPercent%, %iniFile%, convert, percent
Iniwrite %similar%, %iniFile%, options, similarfiles
return
checkBoxes:
Iniread shiftKey, %iniFile%, options, shiftKey
Iniread convDot, %iniFile%, convert, dots
Iniread convMinus, %iniFile%, convert, minus
Iniread convUnderscore, %iniFile%, convert, underscore
Iniread convPercent, %iniFile%, convert, percent
Iniread similar, %iniFile%, options, similarfiles
Guicontrol ,,shiftKey, %shiftKey%
Guicontrol ,,convDot, %convDot%
Guicontrol ,,convMinus, %convMinus%
Guicontrol ,,convUnderscore, %convUnderscore%
Guicontrol ,,convPercent, %convPercent%
Guicontrol ,,similar, %similar%
return
convert:
Iniread convDot, %iniFile%, convert, dots
Iniread convMinus, %iniFile%, convert, minus
Iniread convUnderscore, %iniFile%, convert, underscore
Iniread convPercent, %iniFile%, convert, percent
if convDot = 1
StringReplace rawName, rawName, ., %A_SPACE%, A
if convMinus = 1
StringReplace rawName, rawName, -, %A_SPACE%, A
if convUnderscore = 1
StringReplace rawName, rawName, _, %A_SPACE%, A
if convPercent = 1
StringReplace rawName, rawName, `%20, %A_SPACE%, A
return
ChangeCMI:
RegRead, regTest, HKEY_CLASSES_ROOT, *\shell\FileNanny
transform,eperluette,chr,0x26
Inputbox newCMI, Enter new context menu text, Please choose the text that will appear in the context menu., , , , , , , , %regTest%
If ErrorLevel
{
return
}
else
{
RegWrite, REG_SZ, HKEY_CLASSES_ROOT, *\shell\FileNanny, , %newCMI%
Guicontrol,, currentCMI, Current : %newCMI%
}
return
AddCMI:
RegWrite, REG_SZ, HKEY_CLASSES_ROOT, *\shell\FileNanny, , FileNann&y !
RegWrite, REG_SZ, HKEY_CLASSES_ROOT, *\shell\FileNanny\command, , "%A_ScriptFullPath%" "`%L"
Guicontrol,, CMIb, Remove context menu item
Guicontrol +gremCMI, CMIb
Guicontrol,, currentCMI, Current : FileNann&y !
Guicontrol enable, CMIc
return
RemCMI:
RegDelete HKEY_CLASSES_ROOT, *\shell\FileNanny
Guicontrol,, CMIb, Add context menu item
Guicontrol +gaddCMI, CMIb
Guicontrol,, currentCMI, Current : n/a
Guicontrol disable, CMIc
return
addST:
FileCreateShortcut, %A_ScriptFullPath%, %sendToFolder%\filenanny.lnk
Guicontrol,, STb, Remove 'Send to' shortcut
Guicontrol +gremST, STb
return
remST:
FileDelete, %sendToFolder%\filenanny.lnk
Guicontrol,, STb, Add 'Send to' shortcut
Guicontrol +gaddST, STb
return
Quit:
GuiClose:
GuiEscape:
ExitApp
return
ak_:
Here is FileNanny 1.4 :
Changelog :
- Added the Autoarchive feature to automatically move newly created folders to an archive folder.
Source code :
--- ---;; FileNanny
;; version 1.3.1
;; "Go to your room !"
;; by ak
#SingleInstance ignore
iniFile = %A_ScriptDir%\FileNanny.ini
if 0 = 0
{
gosub CreateGUI
gosub checkboxes
}
else
{
gosub iniVar
GetKeyState kstate, Shift
if (shiftKey = 1 and kstate = "D")
editFolder = 1
if (shiftKey = 0 and kstate = "U")
editfolder = 1
Loop, %0%
{
param := %A_Index%
SplitPath param, fileName, dirName, extension, fileNameNoExt
rawName = %fileNameNoExt%
gosub convert
if editFolder = 1
{
InputBox InputRawName, FileNanny, Name of the folder to create, , 320, 120, , , , , %rawName%
rawName = %InputRawName%
if ErrorLevel
ExitApp
}
dirToCreate = %dirName%\%rawName%
IfNotExist, %dirToCreate%
FileCreateDir %dirToCreate%.FileNanny
IfExist, %dirToCreate%
FileMoveDir %dirToCreate%, %dirToCreate%.FileNanny, 1
fileNewName = %rawName%.%extension%
FileMove %param%, %dirToCreate%.FileNanny\%fileNewName%
;; Similar files detection
if (similar = 1)
{
Loop %dirName%\*.*
{
Splitpath A_LoopFilename, , , ,similarNoExt
if (similarNoExt = rawName)
{
FileMove %dirName%\%A_LoopFilename%, %dirToCreate%.FileNanny\%A_LoopFilename%
}
}
}
;;
FileMoveDir %dirToCreate%.FileNanny, %dirToCreate%, 1
;; Autoarchive
Loop, parse, dirToCreate, \,
folderName = %A_LoopField%
if (autoarchive = 1)
FileMoveDir %dirToCreate%, %archivedir%\%folderName%, 1
}
ExitApp
}
return
CreateGUI:
gui destroy
RegRead, regTest, HKEY_CLASSES_ROOT, *\shell\FileNanny
if strlen(regTest) = 0
{
button1Text = Add context menu item
button1Action = addCMI
}
else
{
button1Text = Remove context menu item
button1Action = remCMI
}
sendToFolder = %UserProfile%\SendTo
ifnotExist %sendToFolder%\filenanny.lnk
{
button2text = Add 'Send to' shortcut
button2action = addST
}
else
{
button2text = Remove 'Send to' shortcut
button2action = remST
}
Gui, Add, Button, x126 y225 w70 h30 gQuit, Quit
Gui, Add, Tab, x3 y5 w315 h260 vSelectedTab, Configuration|Options|Autoarchive
Gui, Font, s9 w600
Gui tab, Configuration
Gui font, norm
Gui, Add, Button, x90 y65 w140 h30 g%button1Action% vCMIb, %button1Text%
Gui, Add, Button, x90 y125 w140 h30 g%button2Action% vSTb, %button2Text%
Gui tab, Options
if strlen(regTest) = 0
{
regTest = n/a
disabledOrNot = disabled
}
Gui, Add, text, x26 y59 w190 h20 vCurrentCMI, Current : %regTest%
Gui, Add, Button, x226 y55 w70 h20 %disabledOrNot% gchangeCMI vCMIc, Change
Gui, Add, GroupBox, x16 y35 w290 h50 , Context menu text
Gui, Add, CheckBox, x16 y95 w300 h30 vshiftKey gini, Holding the Shift key is required to modify `nfolder name before its creation
Gui, Add, GroupBox, x16 y135 w290 h50 , Convert these to spaces
Gui, Add, CheckBox, x30 y150 w50 h30 vconvDot gini, .
Gui, Add, CheckBox, x80 y150 w50 h30 vconvMinus gini, -
Gui, Add, CheckBox, x130 y150 w50 h30 vconvUnderscore gini, _
Gui, Add, CheckBox, x180 y150 w50 h30 vconvPercent gini, `%20
Gui, Add, CheckBox, x16 y195 w300 h30 vsimilar gini, Move similar files
Gui, Tab, AutoArchive
Gui, Add, CheckBox, x16 y35 w300 h30 vAutoArchive gini, Automatically move newly created folders to this folder :
Gui, Add, Edit, x16 y65 w170 h20 vArchiveDir,
Gui, Add, Button, x190 y63 w70 h26 gBrowse, Browse
Gui, Show, autosize, FileNanny
return
iniVar:
Iniread shiftKey, %iniFile%, options, shiftKey
Iniread similar, %iniFile%, options, similarfiles
Iniread autoarchive, %iniFile%, autoarchive, enabled
Iniread archivedir, %iniFile%, autoarchive, archivedir
return
ini:
Gui submit, NoHide
Iniwrite %shiftKey%, %iniFile%, options, shiftkey
Iniwrite %convDot%, %iniFile%, convert, dots
Iniwrite %convMinus%, %iniFile%, convert, minus
Iniwrite %convUnderscore%, %iniFile%, convert, underscore
Iniwrite %convPercent%, %iniFile%, convert, percent
Iniwrite %similar%, %iniFile%, options, similarfiles
Iniwrite %AutoArchive%, %iniFile%, autoarchive, enabled
Iniwrite %archivedir%, %inifile%, autoarchive, archivedir
return
checkBoxes:
Iniread shiftKey, %iniFile%, options, shiftKey
Iniread convDot, %iniFile%, convert, dots
Iniread convMinus, %iniFile%, convert, minus
Iniread convUnderscore, %iniFile%, convert, underscore
Iniread convPercent, %iniFile%, convert, percent
Iniread similar, %iniFile%, options, similarfiles
Iniread AutoArchive, %iniFile%, autoarchive, enabled
Iniread archivedir, %iniFile%, autoarchive, archivedir
Guicontrol ,,shiftKey, %shiftKey%
Guicontrol ,,convDot, %convDot%
Guicontrol ,,convMinus, %convMinus%
Guicontrol ,,convUnderscore, %convUnderscore%
Guicontrol ,,convPercent, %convPercent%
Guicontrol ,,similar, %similar%
Guicontrol ,,AutoArchive, %AutoArchive%
Guicontrol ,,archivedir, %archivedir%
return
convert:
Iniread convDot, %iniFile%, convert, dots
Iniread convMinus, %iniFile%, convert, minus
Iniread convUnderscore, %iniFile%, convert, underscore
Iniread convPercent, %iniFile%, convert, percent
if convDot = 1
StringReplace rawName, rawName, ., %A_SPACE%, A
if convMinus = 1
StringReplace rawName, rawName, -, %A_SPACE%, A
if convUnderscore = 1
StringReplace rawName, rawName, _, %A_SPACE%, A
if convPercent = 1
StringReplace rawName, rawName, `%20, %A_SPACE%, A
return
ChangeCMI:
RegRead, regTest, HKEY_CLASSES_ROOT, *\shell\FileNanny
transform,eperluette,chr,0x26
Inputbox newCMI, Enter new context menu text, Please choose the text that will appear in the context menu., , , , , , , , %regTest%
If ErrorLevel
{
return
}
else
{
RegWrite, REG_SZ, HKEY_CLASSES_ROOT, *\shell\FileNanny, , %newCMI%
Guicontrol,, currentCMI, Current : %newCMI%
}
return
AddCMI:
RegWrite, REG_SZ, HKEY_CLASSES_ROOT, *\shell\FileNanny, , FileNann&y !
RegWrite, REG_SZ, HKEY_CLASSES_ROOT, *\shell\FileNanny\command, , "%A_ScriptFullPath%" "`%L"
Guicontrol,, CMIb, Remove context menu item
Guicontrol +gremCMI, CMIb
Guicontrol,, currentCMI, Current : FileNann&y !
Guicontrol enable, CMIc
return
RemCMI:
RegDelete HKEY_CLASSES_ROOT, *\shell\FileNanny
Guicontrol,, CMIb, Add context menu item
Guicontrol +gaddCMI, CMIb
Guicontrol,, currentCMI, Current : n/a
Guicontrol disable, CMIc
return
addST:
FileCreateShortcut, %A_ScriptFullPath%, %sendToFolder%\filenanny.lnk
Guicontrol,, STb, Remove 'Send to' shortcut
Guicontrol +gremST, STb
return
remST:
FileDelete, %sendToFolder%\filenanny.lnk
Guicontrol,, STb, Add 'Send to' shortcut
Guicontrol +gaddST, STb
return
Browse:
FileSelectFolder, ArchiveFolder, 3
GuiControl,, ArchiveDir, %ArchiveFolder%
Gosub ini
return
Quit:
GuiClose:
GuiEscape:
ExitApp
return
nogojoe:
Here is FileNanny 1.4 : (see attachment in previous post)
Changelog :
- Added the Autoarchive feature to automatically move newly created folders to an archive folder.
-ak_ (November 07, 2008, 01:24 PM)
--- End quote ---
Thanks ak_ for your explanation.
tried the 1.4 version and it works ok except it did not remove (delete) the file that was filenannied .....that was until I hit F5 then it disappeared.
Carried on and tried another file from a folder on the desktop and it did the same didn't remove the file after being filenannied however this time I just closed the folder that file was in and reopened the same folder and it had gone.
Dunno if perhaps you could include a auto-refresh at the end of the code might solve the problem.
Thanks for the autoarchive option that works just great.
nogojoe
ak_:
nogojoe> i assume you use Windows Explorer ? I guess i could send a "F5" to the active window if this window is Explorer, but i don't really like the idea. The main reason is that the problem doesn't come from my code but from the fact that, obvisouly, the file explorer you use doesn't automatically refresh.
nogojoe:
nogojoe> i assume you use Windows Explorer ? I guess i could send a "F5" to the active window if this window is Explorer, but i don't really like the idea. The main reason is that the problem doesn't come from my code but from the fact that, obvisouly, the file explorer you use doesn't automatically refresh.
-ak_ (November 07, 2008, 03:33 PM)
--- End quote ---
that's ok ak_ it's just a minor thing that I can live with .At least I know about it other than that it works just fine.
I guess the file explorer is Window's Explorer as I don't run anything else as a file explorer.
Thanks nogojoe
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version