1

I am trying to create a batch file that will: Start in a minimized state, all documents 3 days old or newer, in a folder. It appears this must be a combination of the for, forfiles and start /min commands.

I have tried:

This script properly opens in my date range, the first document in the directory but will not open any more documents until I close the first document. It will not start them minimized:

forfiles /p "C:\Users\user\Documents\test" /s /d -3 /c "cmd /c @path"

This opens all documents at once, each in its own command prompt window but does not show the document in its appropriate default program, i.e. Microsoft Word for .doc files. It also does not open them minimized:

forfiles /p "C:\Users\user\Documents\test" /s /m *.* /c "cmd /c Start @path" /d -3

This opens all docs but not minimized or in my date range:

for %i in (c:\Users\user\Documents\test\*) do %i

I do not have a script that will open a documents in a minimized state.

Please help! Many thanks!

SachaDee
  • 9,245
  • 3
  • 23
  • 33
T. Allen
  • 11
  • 2
  • 2
    Take a look at the START command and its associated options, `start /?`, _it should give you some ideas_. – Compo Nov 04 '16 at 00:57
  • 2
    `@path` will expand to `"c:\folder\file.ext"`, note the quotes. When using `Start` the **first set of quotes** is the window title. You are creating a command prompt window with a title of the file (but no command to run) which will then exit. When troubleshooting use the `/k` option of `CMD` so you get to see what is happening. Together with @compo comment you have what you need to solve your problem. –  Nov 04 '16 at 01:44
  • Allow me to rephrase my question because I think the original question was too detailed and ended up muddying the issue, so: if possible, with one script, I need to open all documents of any type in a single folder, newer than x days in minimized windows. Thank you for your attention! – T. Allen Nov 04 '16 at 09:43
  • `forfiles`' `/D` switch does not support _3 days old or newer_ due to a design flaw (note that `/D -3` specifies files _modified 3 days ago or earlier_, and `/D +3` specifies files _modified __in__ 3 days or later_); there is a work-around though -- see my answer: [FORFILES date -after- (date calc in cmd file)](http://stackoverflow.com/a/36585535); applied to your situation: `> nul forfiles /D -0 /C "cmd /C if @isdir==FALSE 2> nul forfiles /M @file /D -4 || > con start 0x220x22 @path"` – aschipfl Nov 04 '16 at 09:55

0 Answers0