Page 1 of 1

smart invoke a batch file?

PostPosted: Fri Feb 04, 2011 4:49 pm
by jbhq
anyone got a smart way to run a batch file for a selected folder by sending/storing the folder name to be processed ?
e.g. by utilising a Context Menu or SendTo shortcut
(and save me re-inventing a wheel)

Re: smart invoke a batch file?

PostPosted: Sun Feb 06, 2011 4:30 pm
by jbhq
solved this with this solution (to apply batch file to different folders) ...
I've stuck my batch file with renaming commands in Windows folder and called it f2.bat

I already use AutoHotKey so use this script when in Explorer (XP), triggered with mouse button and r key

~RButton & r::SendInput +{F10}w


+{F10} Shift+F10 opens context menu, which contains a "Command Window Here" entry (with w underscore)

so i'm now in Command Window (for correct folder of files required to be processed)
I key in f2 and it's done.

I'd still like to know of a way of doing this without cheating :roll: using AutoHotKey ...

Adding Folder Context Menu Items

PostPosted: Mon Sep 02, 2013 12:48 am
by truth
The main thing thing to know is that right-clicked File/Folder-Path selections are stored in %1
Very handy when you want to apply a batch to a limited set of graphically chosen files/folders

For WinXP Folders, create the key: HKEY_CLASSES_ROOT\Directory\shell\YourText\command\
You'll have to create both YourText & command (YourText will be an option when right-clicking folders)
Click the newly-created command in left-pane to edit default in the right-pane, it should be in the format below:
cmd /k "cd "%1"&&BatchName.bat"

/k holds the cmd-window open if you need (/c can auto-close it)
cd %1 ensures that your batch runs within the right-clicked folder(s)
As you mentioned, batches must reside somewhere within %path% to omit FullPathBatchNames
You may rename YourText-key at any time for something more descriptive of your batch

This lets you right-click any folder(s) and choose 'YourText' to run the batch within
I'd advise a choice statement in such batches to display a final warning
Otherwise, 1 mis-click could be deadly!