This is my very first post on this forum, and I'm also new to creating batch files (if you put aside batch rendering for autodesk maya). So please excuse me for eventual mistakes or noobish questions ^^.
I have one main folder called "planning", in wich there are subfolders called "[YEAR]", in wich other subfolders called "[month]" contain each several excel sheets. Example :
.../planning/2012/January/Hello World.xlsx
I need to be able to open the latest excel sheet saved in these "sub-sub-folders" in one click.
After hours of googling, i found this code so far :
Code: Select all
@echo off & setLocal enableDELAYedeXpansioN
for /f "tokens=* delims= " %%a in ('dir/b/o-d *.xls') do (
start excel %%a
goto :eof
)
Two problems remain :
- If the most recent filename is, say, "Hello World.xlsx" (with a blank between hello and world), i'll get 2 error message :
Hello.xlsx not found and World.xlsx not found
- Also, this code searches the most recent file in the folder "planning" where the batchfile is placed in. Not in all the subfolders. Is there a way to achieve this ?
If anyone can help me out with this, i would really appreciate it, it would make me win tons of time every day.
RvR