Page 1 of 1

simple .bat copy that i can't do!!

Posted: 04 Mar 2009 11:33
by aftermarket
hi people,

i have a folder that has downloaded films in e\finished downloading when a film downloads it creates a folder within this folder. what i am trying to do is move .avi files that are bigger then say 400 mb in the e;\films folder. i only want to copy the .avi file and not the whole folder. once it has been copied i want the bat file to delete the folder the film came from. any ideas?


thank you

Posted: 19 Mar 2009 10:30
by avery_larry
UNTESTED:

Code: Select all

@echo off

cd /d "e:\finished downloading\somedir"
for %%a in (*.avi) do (
   if %%~za GTR 400000000 move "%%a" e:\films
)
rd /s /q "e:\finished downloading\somedir"

Posted: 19 Mar 2009 15:37
by *SCRIPTER*
---- :idea:

thank you

Posted: 21 Mar 2009 17:49
by aftermarket
your a star!!

Posted: 10 May 2009 10:20
by aftermarket
tried the code today but it didn't work! it deletes everything in the finished directory but doesn't copy anything to the film dir. any ideas?

thanks

Posted: 11 May 2009 14:12
by avery_larry
Hmm . . . Should have thought of this -- are those .avi files larger than ~2 Gb? The if GTR command will choke around 2Gb.

Otherwise, the code seems to test OK. Should have added a cd command to get out of the dir that you're trying to delete:

Code: Select all

@echo off 

cd /d "e:\finished downloading\somedir"
for %%a in (*.avi) do (
   if %%~za GTR 400000000 move "%%a" e:\films
)
cd ..
rd /s /q "e:\finished downloading\somedir"
 


If you're going larger than 2Gb, then we would do this:

Code: Select all

@echo off
setlocal enabledelayedexpansion
cd /d "e:\finished downloading\somedir"
for %%a in (*.avi) do (
   set fsize=%%~za
   if defined fsize call set "fsize=%%fsize:~0,-8%%"
   if 1!fsize! GEQ 14 move "%%a" e:\films
)
cd ..
rd /s /q "e:\finished downloading\somedir"