AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Fast chmoding in FileZilla

 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
iason



Joined: 01 Nov 2005
Posts: 135

PostPosted: Sun Mar 09, 2008 9:02 pm    Post subject: Fast chmoding in FileZilla Reply with quote

This is intended for web administrators, to quickly set permissions on files/folders residing in web servers through FTP. I'm not an expert of the kind, this is just something that has been very helpful to me, and might be of help to others - sorry if i missed something.
For example in a typical scenario, you chmod items to 777, you modify your site, and when finished you chmod back the items one by one (to 755 probably or elsewise) to secure back your code. This is a time-consuming precedure, so let us do it with AHK.

Here they are three scripts:
• one to fastview permissions in a folder
• one to store permissions in an .ini file
• and, one to restore permissions previously stored.

Prerequisites: FileZilla 2.2.32 and AHK 1.0.40.03 - these are my versions, and it surely works.

viewDirAttributes.ahk:
Code:

#SingleInstance, force
CoordMode, Mouse, Screen
CoordMode, ToolTip, Screen

; CONFIGURATION
; unfortunately rightclicking is the way to access "File attributes" dialog (no menu) in FileZilla
; so we must work with mouseclicks
; downward shift of mouseclicks (depending on screen font-size etc.)
MouseVerticalStep = 17

MsgBox, Set in FileZilla the dir you want in remote pane,`nwith all items visible (no scroll).

WinActivate, FileZilla
WinWaitActive, FileZilla
Sleep 50

; trick to get mouse position
ToolTip, `n%A_Tab%CHANGE DIR`, MOUSEOVER FIRST ITEM OF THE LIST AND PRESS F12%A_Tab%`n, 0, 0
KeyWait, F12, D
ToolTip
MouseGetPos, mX, mY
Sleep 100
ControlGetText, whichDir, Edit2, FileZilla

count = 0
Loop
 {
  verticalPosition := mY + count*MouseVerticalStep
  GoSub, PICKthis
  count += 1
 }

ExitApp

;----------------

PICKthis:
WinActivate, FileZilla
WinWaitActive, FileZilla
Sleep 100
MouseClick, Right, %mX%, %verticalPosition%, 1, 0
Sleep 100
Send, {up}{enter}
Sleep 100
IfWinNotExist, Change File Attributes
 {
  MsgBox, %count% items in DIR %whichDir%:`n`n%collect%
  ExitApp
 }
ControlGetText, pickName, Static1, Change File Attributes
IfInString, pickName, Please select the new attributes for the directory
 {
  StringTrimLeft, pickName, pickName, 52
  StringTrimRight, pickName, pickName, 1
 }
IfInString, pickName, Please select the new attributes for the file
 {
  StringTrimLeft, pickName, pickName, 47
  StringTrimRight, pickName, pickName, 1
 }
ControlGetText, pickCHMODvalue, Edit1, Change File Attributes
Sleep 100
Send {Esc}
collect = %collect%`n%pickName%: %pickCHMODvalue%
Return


storeInIniDirAttributes.ahk:
Code:

#SingleInstance, force
CoordMode, Mouse, Screen
CoordMode, ToolTip, Screen

; CONFIGURATION
; downward shift of mouseclicks (depending on screen font-size etc.)
MouseVerticalStep = 17

MsgBox, Set in FileZilla the dir you want,`nwith all items visible (no scroll).
WinActivate, FileZilla
WinWaitActive, FileZilla
Sleep 50
ControlGetText, whichDir, Edit2, FileZilla
StringReplace, REPLwhichdir, whichdir, /, [], All
ToolTip, `n%A_Tab%MOUSEOVER FIRST DIR ON THE LIST AND PRESS F12%A_Tab%`n, 0, 0
KeyWait, F12, D
ToolTip
MouseGetPos, mX, mY

count = 0
Loop
 {
  verticalPosition := mY + count*MouseVerticalStep
  GoSub, PICKthis
  count += 1
 }

ExitApp

;----------------

PICKthis:
WinActivate, FileZilla
WinWaitActive, FileZilla
Sleep 50
MouseClick, Right, %mX%, %verticalPosition%, 1, 0
Sleep 50
Send, {up}{enter}
Sleep 100
IfWinNotExist, Change File Attributes
 {
  IniWrite, %count%, %REPLwhichdir%.ini, Section, HOWMANY
  ExitApp
 }
ControlGetText, pickName, Static1, Change File Attributes
IfInString, pickName, Please select the new attributes for the directory
 {
  StringTrimLeft, pickName, pickName, 52
  StringTrimRight, pickName, pickName, 1
 }
IfInString, pickName, Please select the new attributes for the file
 {
  StringTrimLeft, pickName, pickName, 47
  StringTrimRight, pickName, pickName, 1
 }
ControlGetText, pick, Edit1, Change File Attributes
Sleep 50
Send {Esc}
IniWrite, %pick%, %REPLwhichdir%.ini, Section, %pickName%
Return


restoreFromIniDirAttributes.ahk:
Code:

#SingleInstance, force
CoordMode, Mouse, Screen
CoordMode, ToolTip, Screen

; CONFIGURATION
; Shift downwards of mouseclicks on the list view (depending on screen font etc.)
MouseVerticalStep = 17
; Give enough time to FileZilla TO REFRESH DIRECTORY LIST ONLINE! (in millisecs)
safetyInterval = 3000

MsgBox, Set in FileZilla the dir you want,`nwith all items visible (no scroll)
WinActivate, FileZilla
WinWaitActive, FileZilla
Sleep 50
ControlGetText, whichDir, Edit2, FileZilla
StringReplace, REPLwhichdir, whichdir, /, [], All
IfNotExist, %REPLwhichdir%.ini
 {
  MsgBox, The file %REPLwhichdir%.ini does not exist.`nIt seems you have not collected dir/file attributes for dir "%whichDir%".`n`nExit.
  ExitApp
 }
ToolTip, `n%A_Tab%MOUSEOVER ON FIRST ITEM ON THE LIST AND PRESS F12%A_Tab%`n, 0, 0
KeyWait, F12, D
ToolTip
MouseGetPos, mX, mY

count = 0
Loop
 {
  verticalPosition := mY + count*MouseVerticalStep
  GoSub, RESTOREthis
  count += 1
 }

ExitApp

;----------------

RESTOREthis:
WinActivate, FileZilla
WinWaitActive, FileZilla
Sleep 50
MouseClick, Right, %mX%, %verticalPosition%, 1, 0
Sleep 50
Send, {up}{enter}
Sleep 100
IfWinNotExist, Change File Attributes
 {
  FileRead, readfile, %REPLwhichdir%.ini
  MsgBox, End of script -- %count% items have been restored:`n`n%readfile%
  ExitApp
 }
ControlGetText, pickName, Static1, Change File Attributes
IfInString, pickName, Please select the new attributes for the directory
 {
  StringTrimLeft, pickName, pickName, 52
  StringTrimRight, pickName, pickName, 1
 }
IfInString, pickName, Please select the new attributes for the file
 {
  StringTrimLeft, pickName, pickName, 47
  StringTrimRight, pickName, pickName, 1
 }
IniRead, pickValue, %REPLwhichdir%.ini, Section, %pickName%
ControlSetText, Edit1, %pickValue%, Change File Attributes
Sleep 100
Send {enter}
ToolTip, `n%A_Tab%NOW CHMODING ITEM "%pickName%" ...%A_Tab%`n
Sleep, %safetyInterval%
ToolTip
Return


Quess this will be read from programmers, so the code does not need much explanation. Enjoy.
_________________
help to be helped
Back to top
View user's profile Send private message
polyethene



Joined: 11 Aug 2004
Posts: 5248
Location: UK

PostPosted: Sat Oct 25, 2008 2:55 pm    Post subject: Re: Fast chmoding in FileZilla Reply with quote

iason wrote:
This is a time-consuming precedure
Not if you tick the recurse option.


_________________
GitHubScriptsIronAHK Contact by email not private message.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Guest






PostPosted: Thu Oct 30, 2008 4:04 am    Post subject: Reply with quote

Very Happy Thanks, that certainly is of help, sometimes however refreshing the list on the remote side is more time consuming.
Back to top
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group