Can I do a autorun command for moving folders

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
tweacle
Posts: 71
Joined: 11 Apr 2018 05:38

Can I do a autorun command for moving folders

#1 Post by tweacle » 13 Apr 2018 13:12

Hi

I think this can be done via auto run but I need to check.

Im trying to set up a auto run task to run every night at 00.05 hrs to move files from "C" drive to "S" drive.

What I need is folders in C:/Downloads that start with the letters BTP I need them moved into S:/BTP DOWNLOADS and folders in C:/Downloads that DO NOT start with the letters BTP I need them moving into S:/DOWNLOADS

Any Ideas?

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Can I do a autorun command for moving folders

#2 Post by Squashman » 13 Apr 2018 13:35

You have used the term AutoRun in both of your questions on the forum, but in my opinion you are using the wrong terminology. AutoRun used to deal with programs running when you inserted removable media. That functionality was removed from Windows a while ago. So can you explain to us what you mean by AutoRun?

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

Re: Can I do a autorun command for moving folders

#3 Post by aGerman » 13 Apr 2018 14:05

I think in his former thread he really meant some kind of autorun. Here it's rather a sheduled task where he has to setup a scheduled task in the task scheduler :)

tweacle
Posts: 71
Joined: 11 Apr 2018 05:38

Re: Can I do a autorun command for moving folders

#4 Post by tweacle » 14 Apr 2018 04:21

Apologies yes im confusing you all by keep saying autorun.

Wha im trying to do is automatically move files from one folder to the other at a certain time. I think you are right in saying task scheduler.

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

Re: Can I do a autorun command for moving folders

#5 Post by aGerman » 14 Apr 2018 04:37

The batch code for your task may look like that:

Code: Select all

@echo off &setlocal DisableDelayedExpansion
for /f "delims=" %%i in ('dir /ad /b "C:\Downloads\BTP*"') do robocopy "C:\Downloads\%%i" "S:\BTP DOWNLOADS\%%i" /s /e /move /r:1 /w:1
for /f "delims=" %%i in ('dir /ad /b "C:\Downloads\*"') do robocopy "C:\Downloads\%%i" "S:\DOWNLOADS\%%i" /s /e /move /r:1 /w:1
Create a new folder C:\scheduled and save the script as move_downloads.bat in this folder.

Maybe someone of the native English can provide the SCHTASKS command line to setup the scheduled task. I remember some settings were language dependent. I always use the wizard rather than the SCHTASKS command ...

Steffen

Post Reply