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

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
aftermarket
Posts: 3
Joined: 04 Mar 2009 11:25

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

#1 Post by aftermarket » 04 Mar 2009 11:33

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

avery_larry
Expert
Posts: 391
Joined: 19 Mar 2009 08:47
Location: Iowa

#2 Post by avery_larry » 19 Mar 2009 10:30

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"

*SCRIPTER*
Posts: 18
Joined: 16 Mar 2009 08:18
Location: N/A
Contact:

#3 Post by *SCRIPTER* » 19 Mar 2009 15:37

---- :idea:

aftermarket
Posts: 3
Joined: 04 Mar 2009 11:25

thank you

#4 Post by aftermarket » 21 Mar 2009 17:49

your a star!!

aftermarket
Posts: 3
Joined: 04 Mar 2009 11:25

#5 Post by aftermarket » 10 May 2009 10:20

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

avery_larry
Expert
Posts: 391
Joined: 19 Mar 2009 08:47
Location: Iowa

#6 Post by avery_larry » 11 May 2009 14:12

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"
 

Post Reply