or Connect
AVS › AVS Forum › Video Components › Home Theater Computers › Creating a .bat file for automated moving of files via Scheduled Tasks in Win7HP x64
New Posts  All Forums:Forum Nav:

Creating a .bat file for automated moving of files via Scheduled Tasks in Win7HP x64

post #1 of 8
Thread Starter 
Hi again, all smile.gif

I have a custom built HTPC/DVR in the living room that runs under Windows 7 Home Premium SP1 x64.

I would like to configure the HTPC so that it automatically moves DVR recordings off of the capture hard drives and places them onto another local hard drive. That is, I want to have daily unattended "cut-and-paste" of .ts files from one local hard drive (used for placement of DVR recordings) to another local hard drive (used as a big storage space).

My HTPC/DVR has access to 6 ASTC tuners, and contains multiple internal disk drives which are set up as follows under Win7:

C:\ = NTFS partition on a 128GB SSD used for OS and programs.

E:\ = NTFS partition on a 1TB HDD used as a landing space for recordings made with OTA Tuners 1,2,3.

F:\ = NTFS partition on a 1TB HDD used as a landing space for recordings made with OTA Tuners 4,5,6.

G:\ = NTFS partition on a 4TB HDD used as a large buffer space available for when drives E: and F: start getting full.

What I wish to do, specifically, is the following:

Move *.ts from E: to G:\BUFFER_FOLDER1\, and then...
move *.ts from F: to G:\BUFFER_FOLDER2\.

I figure that this can easily be achieved with a .bat file that is executed daily using Scheduled Tasks in Windows 7. So if anyone has any .bat scripts they could share here, that would be great. Thanks.
post #2 of 8
http://www.howtogeek.com/howto/25046/schedule-synctoy-to-run-automatically-with-task-scheduler-in-windows-7

Or you could try PureSync which has a scheduler built-in.
post #3 of 8
Thread Starter 
Quote:
Originally Posted by amarshonarbangla View Post

http://www.howtogeek.com/howto/25046/schedule-synctoy-to-run-automatically-with-task-scheduler-in-windows-7

Or you could try PureSync which has a scheduler built-in.

Thanks amarshonarbangla. Looked at both suggestions, but I need the files moved rather than copied. The sync tools would be perfect if copying the *.ts files was the goal. I suppose I could set up the sync to occur automatically at a certain time and then manually delete the original files off the DVR HDDs, but I would prefer that the whole process be carried out automatically.

*EDIT*
Actually, I could use the sync utility to make copies, then use a .bat script (+Task Scheduler) to automatically delete the originals afterwards... maybe that's the way to go for my particular need smile.gif

Thank you again for your reply.
post #4 of 8
Thread Starter 
Found a site through Googling that shows command script definitions, syntax, and examples. From reviewing that site, it looks like the MOVE command is what I need.

Source
http://www.scriptcode.com/batchfilecommands/move.html

According to the web page found at the above link:
Quote:
MOVE - Batch File Command

Moves files from one location to another, as opposed to copying. The MOVE command combines COPY and DELETE by copying a file then deleting the original.

Syntax

move [{/y|/-y}] [Source] [target]

Parameters

/y : Suppresses prompting to confirm you want to overwrite
an existing destination file.

/-y : Causes prompting to confirm you want to overwrite an
existing destination file.

Source : Specifies the path and name of the file or files
to move. If you want to move or rename a
directory, Source should be the current directory
path and name.

target : Specifies the path and name to move files to. If
you want to move or rename a directory, target
should be the desired directory path and name.

Examples

MOVE C:\test.txt A:\test.txt, moves the file "test.txt" from
C:\ to the A: drive.

To move all files with the .xls extension from the \Data
directory to the \Reports directory, type the following:

MOVE \data\*.xls \reports\

You may also use MOVE to rename files in the new location.

Example: MOVE C:\test.txt C:\windows\myfile.txt creates a
copy with a new name and deletes the original. Copies and
deletes a file at the same time.

So in order to do what I wrote in my original post:
Quote:
Move *.ts from E: to G:\BUFFER_FOLDER1\, and then...
move *.ts from F: to G:\BUFFER_FOLDER2\.

I should use the following command lines:
Quote:
move e:\*.ts g:\buffer_folder1\
move f:\*.ts g:\buffer_folder2\

When I have a spare moment, I will create the above command script and save it to a batch file, then run it. I'll report back later with the outcome in case anyone is interested smile.gif
post #5 of 8
Puresync has an option to delete files from the original location upon moving.
post #6 of 8
Quote:
Originally Posted by Vlad Theimpaler View Post

Found a site through Googling that shows command script definitions, syntax, and examples. From reviewing that site, it looks like the MOVE command is what I need.

Source
http://www.scriptcode.com/batchfilecommands/move.html

According to the web page found at the above link:
So in order to do what I wrote in my original post:
I should use the following command lines:
When I have a spare moment, I will create the above command script and save it to a batch file, then run it. I'll report back later with the outcome in case anyone is interested smile.gif

You might want to also Google "robocopy". Just sayin'.
post #7 of 8
Thread Starter 
Quote:
Originally Posted by glorpsd View Post

You might want to also Google "robocopy". Just sayin'.

Excellent, thank you, glorpsd, for helping me learn about something new smile.gif

When I reviewed the Wikipedia article at:
http://en.wikipedia.org/wiki/Robocopy

I noticed this statement:
Quote:
File names and wild-card characters (such as "*.*") are not valid source or destination arguments.

This limitation is, unfortunately, a dealbreaker for me. I do appreciate the response, though, and hope to hear from others with additional options. Thank you everybody.
post #8 of 8
Wildcard example in DOS:
Quote:
...
ECHO Start ROBOCOPY to '\\whs\Recorded TV' >>D:\Media\robotv-%COMPUTERNAME%.log
FOR /F "usebackq delims=|" %%i IN (`dir /b "D:\Media\RecTV\*.wtv"`) DO IF NOT EXIST "\\whs\recorded tv\%%i" RENAME "D:\Media\RecTV\%%i" "%%~n%i.wtv-temp"
robocopy "D:\Media\RecTV" "\\whs\recorded tv" *.wtv-temp /LOG+biggrin.gif:\Media\robotv-%COMPUTERNAME%.log /COPYALL /R:5 /NP
ren "\\whs\recorded tv\*.wtv-temp" *.wtv >>D:\Media\robotv-%COMPUTERNAME%.log
ren "D:\Media\RecTV\*.wtv-temp" *.wtv >>D:\Media\robotv-%COMPUTERNAME%.log
FOR /F "usebackq delims=|" %%i IN (`dir /b "D:\Media\RecTV\*.wtv"`) DO IF EXIST "\\whs\recorded tv\%%i" DEL "D:\Media\RecTV\%%i" "%%~n%i.wtv"
...
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Home Theater Computers
AVS › AVS Forum › Video Components › Home Theater Computers › Creating a .bat file for automated moving of files via Scheduled Tasks in Win7HP x64