Page 1 of 1

[Windows7] simple script, I think

Posted: January 17th, 2011, 6:14 pm
by syth
I just want a simple script that copies all the files in the TV category to T:\

(The files are downloaded and processed into C:\TV which I want, I just want them to be copied to T:\ as well. Would be 5 seconds to do this on the Mac or FreeBSD machines, but have no idea where to even begin on Windows.)

[edit]
Oh, I have the SDK for UNIX-Applications installed in Win7, which I think has at least C Shell buried somewhere, so could I use that for post processing?

[edit2]
Inc ase anyone else reads this, this APPEARS to be working, but I've not tested it much yet.

Code: Select all

@echo off
set myFile=%1
set myDest=T:\
copy %myFile% %myDest%
[edit]
OK, it works, but it copies the file to t:\ instead of the folder with the file in it. that is to say is copies "TV show.s01e01.avi" instead of "TV Show\TV show.s01e01.avi"

If anyone is reading this and can enlighten me? Or do I just install rsync on the windows machine? (I am trying to avoid installing anything at all extra on the windows machine as it is exclusively a video source for the projector)

Re: [Windows7] simple script, I think

Posted: January 21st, 2011, 4:25 am
by syth
If someone could take a look at this and give me some pointers I would really appreciate it. I seem to be stuck at this point.

Re: [Windows7] simple script, I think

Posted: January 21st, 2011, 8:33 pm
by minimeh
syth wrote: If someone could take a look at this and give me some pointers I would really appreciate it. I seem to be stuck at this point.
The simplest way to accomplish what you are looking for, I think, is:

Code: Select all

@echo off
xcopy /d /s /y %1 %2
where

Code: Select all

    /d   Copies only those files whose source time is newer than the destination time.
         This will keep from copying the same stuff over and over
    /s   Copies directories and subdirectories except empty ones.
    /y   Suppresses prompting to confirm you want to overwrite an existing destination file.
    %1   Is the source folder.
    %2   Is the destination folder.
The idea is to pass the folder that contains your TV files, not the just downloaded file name itself, as parameter 1. Then, as you do now, pass the destination as the second parameter.  The remaining parameters will cause xcopy to traverse through all directories in your source folder and ensure that a copy of every file found will be made to the destination folder, recreating the source folder structures as it goes. It will never re-copy something that has already been copied.

It's a shotgun approach but might accomplish what you want.

Re: [Windows7] simple script, I think

Posted: January 24th, 2011, 4:26 pm
by syth
minimeh wrote:
The simplest way to accomplish what you are looking for, I think, is:

Code: Select all

@echo off
xcopy /d /s /y %1 %2
where

Code: Select all

    /d   Copies only those files whose source time is newer than the destination time.
         This will keep from copying the same stuff over and over
    /s   Copies directories and subdirectories except empty ones.
    /y   Suppresses prompting to confirm you want to overwrite an existing destination file.
    %1   Is the source folder.
    %2   Is the destination folder.
The idea is to pass the folder that contains your TV files, not the just downloaded file name itself, as parameter 1. Then, as you do now, pass the destination as the second parameter.  The remaining parameters will cause xcopy to traverse through all directories in your source folder and ensure that a copy of every file found will be made to the destination folder, recreating the source folder structures as it goes. It will never re-copy something that has already been copied.
OK, but %1 is passed by sabnzbd and %2 doesn't contain the destination. This is the script that fires after the download is completed. I will try the xcopy and see what happens. I am still having to manually put the files into the right folders.

It's odd, since with rsync I just say `rsync $1 /path/to/destination` and I get 'series/series.s01e01.avi' at destination.

Re: [Windows7] simple script, I think

Posted: January 28th, 2011, 11:13 am
by syth
OK, I've been mucking about with this and nothing I do seems to preserve the directory the file is in.

with sabnzb and rsync, I just did

Code: Select all

rsync -aP "$1" /TV
which resulted in /TV/Series/Series.S01E01 - Name of ep.avi

on Windows if I try to copy (or xcopy) I get instead:

/TV/Series.S01E01 - Name of ep.avi

I can't be the only one that has this issue. How are people moving files under windows and preserving the folder/file structure?

Re: [Windows7] simple script, I think

Posted: February 5th, 2011, 6:34 am
by syth
OK, this seems to work for me, preserving the folders and all. I can't seem to use the %1 that sabnzb passes to the script.

Code: Select all

@echo off
set myFile=c:\completed\TV
set myDest=T:\
Robocopy /e %myFile% %myDest%
set myDest=C:\TV
Robocopy /e /MOVE %myFile% %myDest%