Trying to move files of a certain size out of a folder tree
Moderator: DosItHelp
Trying to move files of a certain size out of a folder tree
Hi all,
I dl tv eps using a Usenet client (Mimo) that parity checks, repairs if needed, and then unrars the file into a folder using the rar name as a folder name. Since it also uses the usenet group name of the download as a preceding folder name, the end result is kind of messy. For example:
d:\mimo\alt.binaries.hdtv\csi.s12e02\csi.s12e02.mkv
d:\mimo\alt.binaries.hdtv\csi.s12e03\csi.s12e03.mkv
d:\mimo\alt.binaries.teevee\30.rock.s04e02\30.rock.s04e02.mkv
d:\mimo\alt.binaries.teevee\30.rock.s04e04\30.rock.s04e04.mkv
d:\mimo\alt.binaries.dvd\Louie.Season.1\Louie.Season.1.iso
What I then have to do is move the .mkv, .iso, .avi files etc manually into another folder (d:\media) using the gui.
This is time consuming and kind of boring. I use a File Finder search window, then order by size, select the media, and drag them into the right place. Then I have to delete all files and folders below d:\mimo.
(There are often .par2 and .nfo files left in the subfolders that can be deleted.)
I would love to have a batch file do this for me. I have no idea how.
What would be ideal would be this:
1 Find all files below d:\mimo larger than 100 meg.
2 Move all these files to d:\media. In case of a duplicate file name, pause & warn.
3 Tree Delete of all files and folders below d:\mimo, leaving d:\mimo intact and empty.
Is this even possible?
Many thanks!
I dl tv eps using a Usenet client (Mimo) that parity checks, repairs if needed, and then unrars the file into a folder using the rar name as a folder name. Since it also uses the usenet group name of the download as a preceding folder name, the end result is kind of messy. For example:
d:\mimo\alt.binaries.hdtv\csi.s12e02\csi.s12e02.mkv
d:\mimo\alt.binaries.hdtv\csi.s12e03\csi.s12e03.mkv
d:\mimo\alt.binaries.teevee\30.rock.s04e02\30.rock.s04e02.mkv
d:\mimo\alt.binaries.teevee\30.rock.s04e04\30.rock.s04e04.mkv
d:\mimo\alt.binaries.dvd\Louie.Season.1\Louie.Season.1.iso
What I then have to do is move the .mkv, .iso, .avi files etc manually into another folder (d:\media) using the gui.
This is time consuming and kind of boring. I use a File Finder search window, then order by size, select the media, and drag them into the right place. Then I have to delete all files and folders below d:\mimo.
(There are often .par2 and .nfo files left in the subfolders that can be deleted.)
I would love to have a batch file do this for me. I have no idea how.
What would be ideal would be this:
1 Find all files below d:\mimo larger than 100 meg.
2 Move all these files to d:\media. In case of a duplicate file name, pause & warn.
3 Tree Delete of all files and folders below d:\mimo, leaving d:\mimo intact and empty.
Is this even possible?
Many thanks!
Re: Trying to move files of a certain size out of a folder t
Plain batch math tops out at 2 GB so extra processing needs to be done to handle large filesizes.
A GUI solution I would use to move all files over 100 MB to a second folder is Total commander.
Steps
1) put d:\media and d:\mimo in each side of the two pane window.
2) press tab to highlight d:\mimo
3) press control B to list every file in the subdirectory tree, sort by size with control F5
4) hold shift and move the cursor down, marking all the largest files.
5) press F6 to move all marked files to d:\media.
6) Total commander will stop and warn on each duplicate filename, or let you rename, or automatically add a number to all dup filenames.
7) refocus on d:\mimo and highlight all folders and delete.
Total commander at http://www.ghisler.com is un-crippled shareware so you can try it to see how you go with it. It's my swiss army knife and it does so much more.
You can also save the starting folders and sorting behaviour by saving settings.
A GUI solution I would use to move all files over 100 MB to a second folder is Total commander.
Steps
1) put d:\media and d:\mimo in each side of the two pane window.
2) press tab to highlight d:\mimo
3) press control B to list every file in the subdirectory tree, sort by size with control F5
4) hold shift and move the cursor down, marking all the largest files.
5) press F6 to move all marked files to d:\media.
6) Total commander will stop and warn on each duplicate filename, or let you rename, or automatically add a number to all dup filenames.
7) refocus on d:\mimo and highlight all folders and delete.
Total commander at http://www.ghisler.com is un-crippled shareware so you can try it to see how you go with it. It's my swiss army knife and it does so much more.
You can also save the starting folders and sorting behaviour by saving settings.
Re: Trying to move files of a certain size out of a folder t
Thanks for the idea. I actually already use a program similar to that, called PowerDesk.
It's rather more powerful, but of course it's not shareware.
The batch file option really would be preferable though.
Did you mean 100 Mb when you put 100 gig?
Thanks.
It's rather more powerful, but of course it's not shareware.
The batch file option really would be preferable though.
Did you mean 100 Mb when you put 100 gig?
Thanks.
Re: Trying to move files of a certain size out of a folder t
yes, I edited the 100 GB figures.
If the files re guaranteed to be below 2GB then batch could work pretty easily.
If the files re guaranteed to be below 2GB then batch could work pretty easily.
Re: Trying to move files of a certain size out of a folder t
This should work - hasn't been tested very much. The RD command will only be echoed to the scree so remove that ECHO statement to enable the deletion if the rest works.
Code: Select all
@echo off
del "%userprofile%\desktop\file.log" 2>nul
pushd "d:\mimo" || goto :EOF
for /f "delims=" %%a in ('dir /a:-d /b /s') do (
if %%~za GTR 100000000 (
if not exist "d:\media\%%~nxa" (
move "%%a" "d:\media" >nul
) else (
echo file exists: "%%a">>"%userprofile%\desktop\file.log"
)
)
)
if exist "%userprofile%\desktop\file.log" (
echo check "%userprofile%\desktop\file.log"
) else (
echo rd /s /q "d:\mimo" 2>nul
)
popd
pause
Re: Trying to move files of a certain size out of a folder t
Wow. That's really kind of you. I thought I knew a bit about batch files but this is way beyond what I've ever done.
The only sand in the vaseline is that the files I need to move are almost always .mkv files which are usually around 1 Gig each. And more often than not there are several of them.
If the 2 gig limit for dos means that wouldn't work, perhaps we could change the size filter for a file filter? (*.mkv)
The only thing I might do then is a
dir /s
pause
deltree
and if the size of everything that's left is just a few hundred k or a couple of meg, I can allow the deltree command to proceed.
If it's much larger I'd know there's something left in a folder that isn't mkv. Like an iso or avi or mp4 or whatever. I'd then move that manually.
Pity, the size solution is so much more elegant.
Thank you so much for your help with this!
Will
The only sand in the vaseline is that the files I need to move are almost always .mkv files which are usually around 1 Gig each. And more often than not there are several of them.
If the 2 gig limit for dos means that wouldn't work, perhaps we could change the size filter for a file filter? (*.mkv)
The only thing I might do then is a
dir /s
pause
deltree
and if the size of everything that's left is just a few hundred k or a couple of meg, I can allow the deltree command to proceed.
If it's much larger I'd know there's something left in a folder that isn't mkv. Like an iso or avi or mp4 or whatever. I'd then move that manually.
Pity, the size solution is so much more elegant.
Thank you so much for your help with this!
Will
Re: Trying to move files of a certain size out of a folder t
WillS wrote:The only sand in the vaseline is that the files I need to move are almost always .mkv files which are usually around 1 Gig each. And more often than not there are several of them.
If the 2 gig limit for dos means that wouldn't work, perhaps we could change the size filter for a file filter? (*.mkv)
It's not cumulative and the limit is only when checking the size of a file. This will work as it is for all files, if each file is under 2GB (power of 2).
If any files are over 2GB then there will probably be an error message and that file will not be moved.
The only thing I might do then is a
dir /s
pause
deltree
and if the size of everything that's left is just a few hundred k or a couple of meg, I can allow the deltree command to proceed.
Deltree is a command from MSdos and Win9x. It no longer exists in NT class windows but I gather you are using NT class windows - or the batch file above will not run anyway.
Replace this section below with the section below it. There are two pause prompts to allow some leeway if a key is pressed without thinking.
Code: Select all
) else (
echo rd /s /q "d:\mimo" 2>nul
)
popd
pause
Code: Select all
) else (
dir /s
echo press control C to abort or let it continue to remove the files/folders in "d:\mimo"
pause
pause
rd /s /q "d:\mimo" 2>nul
echo Done
)
popd
pause
Re: Trying to move files of a certain size out of a folder t
Thank you so much!
I shall experiment and report back my results.
I really appreciate the time you've taken to help me with this.
I shall experiment and report back my results.
I really appreciate the time you've taken to help me with this.
Re: Trying to move duplicate file
I've used duplicate files deleter software that detects duplicate files and it's quite user friendly. It can detect file format. You can delete the whole files at one click or can delete desired one.