start bat when open folder

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
svenjatzu
Posts: 2
Joined: 11 Dec 2017 17:52

start bat when open folder

#1 Post by svenjatzu » 11 Dec 2017 20:47

hi

is there any option to start a bat to move my logfiles form server by putting the bat inside the folder and just open the folder?

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: start bat when open folder

#2 Post by aGerman » 12 Dec 2017 06:51

No there is no option. If "open the folder" means you display the folder content in the file explorer then you would have to programmatically change the behavior of explorer.exe (or whatever file explorer you use).

If the target where to move the log files is always the same then you could place a script into the SendTo folder (probably "%APPDATA%\Microsoft\Windows\SendTo") to have it in the "Send to" menu item if you right click on the folder.

Code: Select all

@echo off &setlocal
if "%~1"=="" exit /b
if not exist "%~1\" exit /b

for /r "%~1" %%i in ("*.log") do (
  echo found "%%~i"
)

pause
Instead of ECHOing the found files you have to apply your move command. But since you don't provide detailed information I can't help any further.

Steffen

Post Reply