ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Finished Programs

DONE: Removing zero length files recursively at command-line

<< < (3/4) > >>

MilesAhead:
I'm not familiar with SharePoint, so bear with me.  When you say you want the hotkey program or batch to start in the location you are in, what are you in exactly?  I'm wondering if there may be a way to use the clipboard to get the folder location or whatnot.

questorfla:
PS:  Miles ahead.  Excuse the re:use of my original post, the SharePoint problem was resolved in the 2nd post and i just kept going.  Hated to wast a good thread :)
To be honest, anything to do with SharePoint is probably going to be a dead end:  WAY too many issues to deal with.  So.. I Segued into creating an automated script used for creation of a custom very specialized website-app.  More la web-app than a website.   Just trying to get each step to run as a script.

I did finally get the last one to work but not as easily as i would like
using Shift plus right click  can open a  command prompt in the directory I want the folder created in
then run the batch file as is and it works fine even though it is located at c:\.  It let me enter the name i wanted and created that folder and unzipped the files into it.  What i wanted was a way to pass the current location i am in when i press a hot-key combo to the batch file.  dropping out to a command prompt wasn't that bad,  it just seems unnecessary.  
Heck this part is easy,  next this i have to do is use that SAME name to change a line of text in two of the files that go in that directory, as well as use that same name to create a MySQL database.  The command line for MySQL I do have somewhere.  None of this is "essential" i am just trying to see if it would be possible to automate the whole process since it never changes and i have to do it several times a day

MilesAhead:
I'm not sure about the second part but if you have an Explorer folder window open and an existing folder selected then an ahk script would be able to get the folder path(if it is a regular folder, not Computer or some other shell object) and chop off the path to the last backslash to get the local folder name.  It could use ShellExecute to run the batch file with the folder path as working directory etc..

So if that part is worth doing depends how much typing you have to do for the manual command prompt bit.  Only you would know if your time is better spent on the next stage or making the solved task a bit easier.  :)

4wd:
The problem I'm having trying to understand your scenario is you still haven't described the methodology you use before you run the command file.

ie.
a) Do you run this from a CLI open at the required path, (in which case put the command file in the command PATH somewhere, or add to the PATH, and call it without using a hotkey).
b) Do you run this from Explorer somehow, (in which case use my program here to copy the current path to the clipboard and then use GetClip in your command file to retrieve it when you run it via hotkey).
c) Running it from the Start->Run prompt, (in which case use a real CLI :) ).

Or the alternative is write something in a language that will let you do exactly what you want.

Addendum: qExClip, a slightly modified version of ExClip.


--- Code: AutoIt ---#Region ;**** Directives created by AutoIt3Wrapper_GUI ****#AutoIt3Wrapper_UseUpx=n#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****; http://www.autoitscript.com/forum/topic/89833-windows-explorer-current-folder/page__st__40#entry973904#include <Array.au3> Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ComErrFunc") If $CmdLine[0] = 1 Then        $sCmd = $CmdLine[1]        _ExClip(True)Else        _ExClip(False)EndIf  Func _ExClip($temp)        $hExplr = WinActive("[REGEXPCLASS:(Explore|Cabinet)WClass]")        If $hExplr <> '' Then                $aSelection = _ExplorerWinGetSelectedItems($hExplr);~              _ArrayDisplay($aSelection)                If $aSelection[0] = 0 Then                        If StringLeft($aSelection[1], 2) <> '::' Then                                If Not $temp Then                                        ClipPut($aSelection[1])                                Else                                        ShellExecute($sCmd, $aSelection[1], $aSelection[1])                                EndIf                        EndIf                Else                        If Not $temp Then                                ClipPut($aSelection[2])                        Else                                ShellExecute($sCmd, $aSelection[2], $aSelection[2])                        EndIf                EndIf        EndIfEndFunc   ;==>_ExClip   ; ========================================================================================================================== ; Func _ObjectSHFolderViewFromWin($hWnd);; Returns an 'ShellFolderView' Object for the given Window handle;; Author: Ascend4nt, based on code by KaFu, klaus.s; ========================================================================================================================== Func _ObjectSHFolderViewFromWin($hWnd)        If Not IsHWnd($hWnd) Then Return SetError(1, 0, 0)        Local $oShell, $oShellWindows, $oIEObject, $oSHFolderView         ; Shell Object        $oShell = ObjCreate("Shell.Application")        If Not IsObj($oShell) Then Return SetError(2, 0, 0)         ;   Get a 'ShellWindows Collection' object        $oShellWindows = $oShell.Windows()        If Not IsObj($oShellWindows) Then Return SetError(3, 0, 0)         ;   Iterate through the collection - each of type 'InternetExplorer' Object         For $oIEObject In $oShellWindows                If $oIEObject.HWND = $hWnd Then                        ; InternetExplorer->Document = ShellFolderView object                        $oSHFolderView = $oIEObject.Document                        If IsObj($oSHFolderView) Then Return $oSHFolderView                        Return SetError(4, 0, 0)                EndIf        Next         Return SetError(-1, 0, 0)EndFunc   ;==>_ObjectSHFolderViewFromWin ; ==========================================================================================================================; Func _ExplorerWinGetSelectedItems($hWnd);;; Author: klaus.s, KaFu, Ascend4nt (consolidation & cleanup, Path name simplification); ========================================================================================================================== Func _ExplorerWinGetSelectedItems($hWnd)        If Not IsHWnd($hWnd) Then Return SetError(1, 0, '')        Local $oSHFolderView        Local $iSelectedItems, $iCounter = 2, $aSelectedItems[2] = [0, ""]         $oSHFolderView = _ObjectSHFolderViewFromWin($hWnd)        If @error Then Return SetError(@error, 0, '')         ;   SelectedItems = FolderItems Collection object->Count        $iSelectedItems = $oSHFolderView.SelectedItems.Count         Dim $aSelectedItems[$iSelectedItems + 2] ; 2 extra -> 1 for count [0], 1 for Folder Path [1]         $aSelectedItems[0] = $iSelectedItems        ;   ShellFolderView->Folder->Self as 'FolderItem'->Path        $aSelectedItems[1] = $oSHFolderView.Folder.Self.Path         ;   ShellFolderView->SelectedItems = FolderItems Collection object        $oSelectedFolderItems = $oSHFolderView.SelectedItems         #cs                ; For ALL items in an Explorer Window (not just the selected ones):                $oSelectedFolderItems = $oSHFolderView.Folder.Items                ReDim $aSelectedItems[$oSelectedFolderItems.Count+2]        #ce         For $oFolderItem In $oSelectedFolderItems                $aSelectedItems[$iCounter] = $oFolderItem.Path                $iCounter += 1        Next         Return SetExtended($iCounter - 2, $aSelectedItems)EndFunc   ;==>_ExplorerWinGetSelectedItems Func _ComErrFunc($oError)        ConsoleWrite("COM Error occurred:" & @CRLF & _                        "Number: " & @TAB & $oError.number & @CRLF & _                        "Windescription:" & @TAB & $oError.windescription & @CRLF & _                        "Description is: " & @TAB & $oError.description & @CRLF & _                        "Source is: " & @TAB & $oError.source & @CRLF & _                        "Helpfile is: " & @TAB & $oError.helpfile & @CRLF & _                        "Helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _                        "Lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _                        "Scriptline is: " & @TAB & $oError.scriptline & @CRLF & _                        "Retcode is: " & @TAB & $oError.retcode & @CRLF & @CRLF)EndFunc   ;==>_ComErrFunc
Command file, preload.cmd

--- Code: Text ---@echo offecho.rem preload.cmd [folder]remrem Where [folder] = optional folder to create subfolder inremrem  If folder passed as arg, use it if it exists, assume it is runrem  from CLI in required folder if it does not.if "%~1"=="" goto :Requestif not exist "%~1" (  echo Folder does not exist  echo.  goto :Request)pushd "%~1" :Requestrem There is a SPACE at the end of the follwoing lineset /p newdir=Entername: if "%newdir%"=="" goto :ENDcall :Extract "%newdir%"goto :END :Extractset ndir="%~1"md %ndir%pushd %ndir%7za.exe e preload.zipcd > path.txtgoto :EOF :END
Clavier+ setup:
DONE: Removing zero length files recursively at command-line

What it does:

ONLY works with Explorer, navigate to a folder or select one and then press the Clavier+ hotkey, (Alt+F5 in this case).


* Clavier+ calls qExClip.exe with the command file as an argument.
* qExClip.exe grabs either the path of the active Explorer window or the full path of the first selected item.
* This path is then passed as an argument to the command file, (preload.cmd in this case), to be used however.  If no args were provided for qExClip then the path is copied to the clipboard.
* preload.cmd can be run from the CLI also, (with or without args), if passed an arg it will pushd to the folder before continuing with asking folder name, extracting, etc.
OK, the WARNINGS bit:

* Haven't bothered to check whether any item selected is a file - you can do this easily enough in the command file if really necessary.
* Haven't bothered testing to see whether the arg passed to qExClip exists, (get it right).
* Fix any paths to executables/archives in the command file as necessary.
It worked here, doesn't hold that it'll work for you.

questorfla:
You guys are great :-* (and gals if any are reading)  As you can see, I have too much time on my hands because all my efforts are basically just trying to find different ways to do things when the normal ones work fine.
I think too much.  DC has always been a great sounding board to learn new ways of thinking.  Many of the tools you mention are apps I have never heard of and each has a special niche on the "tool-board" in any programmers workshop.

Heck, I still enjoy writing webpages one html at a time  :o!!

Everything we use is already done in machine-code or binary such that I don't even understand what is done to get from point A to point Z. I can already see the day coming (Like NOW!)  when you will just type in a starting point and the end result and let the system tell YOU how to get there.  Or worse, just DO it without telling us outdated "wet-ware"  users HOW.  But it will work and "the ends" will always justify the "means" in the business world.

This is more like doing crossword puzzles just to feel like humans are still a necessary component in reality.  Just doing it to see if it can be done.  I appreciate the interaction with people who also like to take things apart to see how they work.  Different points of view and alternate ways to reach the same solution.  It doesn't seem to me that there are as many around as there used to be.  To that end, DC has become a fantastic opportunity to meet some really nice people almost all of whom are far better at this than I will ever be.    All of your advice and methods are certainly capable of doing the job.  I save every reply to every post I make just to review them when I need a fresh viewpoint on anything.

I could certainly be more descriptive of the task at hand in a PM but I hate to trash up a Public Forum with the banality of WHY I am even pursuing this.  In the end, it is an effort to do something that shouldn't even be done at all.  Unfortunately, this is what I have to do to make a living at this point.  And I am trying to find ways to at least make it interesting rather than just  ;) a "daily grind"  :'(.

I have yet to find a single "wish list" that I could present on DC and not have at least 4 or 5 people chime in with multiple ways to accomplish every item.  Makes me feel better to know there are still people in the world who will do this.  Not just the ones who use a microwave oven to boil water without ever wondering WHY it gets hot without fire.

Thanks to all of you who offer viewpoints on such banalities as the ones I present.  Your input is appreciated in more ways than just the "How" for a stupid question.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version