Question Locked

How to pass filename from Windows to DOS?

0 helpful
6 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi,

Is there anyway to pass a selected filename to DOS shell. Following scenario will explain the question better.

A person right clicks on a file (let's say abc.txt) in Windows Explorer and clicks on "Mark Reviewed" (as an example). It should open Dos shell (cmd.exe) and executes "move abc.txt C:\Reviewed\"

I can add "Mark Reviewed" to the context menu using registry and also open cmd.exe but once DOS shell is open I do not know which file was selected.

I implemented similar for Folders and that works but I could not figure our for Files. Below is the script for Folders.

**********SCRIPT BEGINS****************

cd %1
cd > %temp%\TEMPdir.txt
FOR /F "delims=" %%a in (%temp%\TEMPdir.txt) do set foldertomove=%%a
del %temp%\TEMPdir.txt
move "%foldertomove%" C:\Reviewed

********SCRIPT ENDS******************

Any suggestions?

Ahmad

6 replies

by tony hopkinson

why you don't just move the file in the context action....
But if you want to do it in the shell

The you create a cmd file with "Move abc.txt C:\Reviewed" as the content and then execute that in the shell and then to be neat delete the cmd file.

You if you can find one that will fit can find a bit of coe that will do this for you, personally I'd try to avoid using the shell at all for this.

by ahmad

Consider following folders and subfolders.

> Job1
>> Not Reviewed
>> Reviewed
> Job2
>> Not Reviewed
>> Reviewed
> Job3
>> Not Reviewed
>> Reviewed

Employees pick a file from "Not Reviewed" folder. Once the file has been reviewed, it should be moved to "Reviewed" Folder which may be hidden from that specific employee.

So I needed to either add a button in toolbar or an option in the context menu which would move that file to "Reviewed" folder specific to that Job (Job1, Job2, etc.)

Since destination folder could be different for each job so I needed to determine the path dynamically.

Below is the working script that solved my problem.

cd..
cd > %temp%\Tempdir.txt
FOR /F "delims=" %%a in (%temp%\Tempdir.txt) do set parentdir=%%a
del %temp%\Tempdir.txt
move %1 "%parentdir%\Reviewed

by tony hopkinson

I could do it in code in minutes, scripting is something I rarely do, under windows anyway.

by ahmad

i didn't think about vbscript at all. i will look if that works in my situation or not.

in the meantime i found that "%1" variable already contains the filename and path so that made life much easier.

If in DOS shell I simply run

move %1 C:\Reviewed

that works.

Thanks everyone.

This discussion is closed to new replies.