and thank you for any help. I have tried searching for an example on how to accomplish the following, but haven't found anything. Any help would be appreciated as I have no experience in creating a BAT file!
I have a third party program that records audio, and generates an .mp3 file from it. Every 24 hours, it generates a new folder, and begins the process all over again. The problem is, even the slightest bit of sound will generate an .mp3 file. I am left with thousands of .mp3 files that are less than 1 second. I would like to delete all audio files in all of the subdirectories with a length of less than 2 seconds. How can I go about this, and is a BAT file the correct way to accomplish this? The manual way of sorting the files in the many, many directories is a very time consuming process as 20 - 30 days of files will be generated before I am able to go through them.
For a GUI solution: The shareware uncrippled Total Commander can list a full directory tree (control B) and sort by filesize (control F6) and can also display only MP3 files if needed.
This task would just need you to mark the filesizes less than x MBytes in a single pane and then you can delete them all at once.
Another solution is available with a batch file to delete MP3 files of 2.999 seconds or below:
- change [210] to [10] to delete files up to 1.999 seconds.
Download Mediainfo command line version from SourceForge
Change the path to the executable in line 2 below
Launch this batch file in the main folder of the tree of files
If the del commands you see on the screen are right then remove the echo and run it again to delete the files.
#echo off
set "exe=c:\Util\MediaInfo\MediaInfo.exe"
for /r %%a in (*.mp3) do (
"%exe%" -f "%%a" |find "Duration" | findstr /r ": 00:00:0[210]" >nul && echo del "%%a"
)
pause
Related
I’ve created (well, lifted) a script for powershell to monitor a folder for new files, when new files are added it runs the following batch file to generate checksums:
for %%a in (*.txt) do md5sum "%%a" >> "%%a.md5"
Files are regularly being added to the folder so I only want the script to run on the new files. At the moment it runs from scratch each time generating checksums for the same file over and over. I tried an IF NOT EXIST statement but this only checks the folder for a single instant:
if not exist "*.txt.md5" (for %%a in (*.txt) do md5sum "%%a" >> "%%a.md5")
I presume I need to scan the folder, generate a list of files and then skip over the ones that have checksums? This is where it goes a bit over my head - can anyone advise?
One thing to note - it’s important each file has a separate checksum (e.g. File.txt - File.txt.md5) opposed to generated in a single list, as the files go their separate ways.
Thank you!
1st off I am not very familiar with advanced programming. I have been following examples and trial and erroring things sometimes with not the right result.
I was up half the night trying to get this to work and was so close but not quite there.
Basically I have a folder structure like this.
JOB NUMBER/Photos
In the photo folder there are 2 sub folders Hi-Res & Low-Res
I need a bat file in the Photos folder that will zip only the JPG in folder Low-Res then name the output zip file as JOB NUMBER - Photos.zip and save it to the photo folder.
On top of this once I had it working I need the zip files to be limited on their size. They must be not larger than 6mb so if they need splitting a simple 01 02 .... Can be prefixed to the zip name.
I briefly saw that you could split the output based on size but didn't get that far!
Any help would be a life saver!!
UPDATE
My code so far.
for %%A in ("%%~dp0\..") do 7z a -tzip "%%~fA-Photos.zip" "Low-Res"
UPDATE
#JonathonReinhart
This gets the Low-res contents zipped & saved back into the Low-res folder which will be fine I just cant get the name on the zip file right. At the moment it saves as Photos-Photos.zip
for %%A in ("Low-res\Photos") do 7z a -tzip "%%~fA-Photos.zip" "Low-Res"
Test this in the photos folder.
#echo off
for %%z in ("%cd%") do (
for %%a in ("%%~dpz%\.") do (
7z a -tzip "%%~nxa-%%~nxz.zip" "Low-Res\*"
)
)
pause
Im trying to move a picture in every zip folder in current directory. I searched online for some guidance on how to do it using batch (.bat) and the only solution I figured out is to make a macro of it but it takes too long for it to complete.
Edit:
I have 50 zip folders which I want to add a picture inside each one in a faster way other than draging the picture each time inside each of the 50 zip folders.
I would appreciate any other ideas and help you could offer.
Test this on some sample zip files in a test folder. It assumes 7-zip is in the folder shown.
It's not so much faster as it is easier, without manually manipulating the files.
The actual zipping speed will be pretty much the same.
#echo off
for /f "delims=" %%a in ('dir *.zip /b /a-d') do (
"C:\Program Files\7-Zip\7z.exe" a "%%a" "my-picture.jpg"
)
pause
Adds (or updates) README.txt in the zipfiles foo.zip and bar.zip from README.txt in the current directory:
$ for f in foo.zip bar.zip ; do zip -u $f README.txt ; done
You can package files into a zip file using the Winzip utility. It must be installed on your computer. Follow these steps:
Select the files you need and click on any of the selected ones.
Select Add to Zip
In the Add window, in the Add to Archive field, specify the path and name of the archive to be created.
The ZIP file is saved at the path you specified.
I have a .bat file that runs 7-zip to compress all files in a directory. The files range in size from 1mb to 500mb and there are 10 files. Every 15 mins a scheduled backup program overwrites 5 of the 10 files. Those 5 files are usually the smallest and the quickest to compress, but 7-zip starts with the largest file first thus missing the 5 files within the 15 minutes. How do I get 7-zip to start with the smallest file first. Any help would be much appreciated.
c:
cd "\Program Files\7-Zip"
7z a C:\WEBDATA C:\FILE1.BAK C:\FILE2.BAK C:\FILE3 C:\FILE4 C:\FILE5 etc...
If all of the files are in the same directory, you can use the sort feature of the dir command to add files to the archive one at a time.
For example, if the files to back up are in a subdirectory called 'files':
for /f %%N in ('"dir /A-D /O:S /B files"') do (
7z a backup.7z files/%%N
)
Based on your description this should be sufficient, but if the files are in various locations you may need to get fancier. I haven't tried it myself, but I would expect you could loop through a list of directories, writing each size / filename to a temporary file, then using the sort command on that file.
Is it possible to create a DOS script that will move 2000 files to another folder every 10 minutes?
For example:
C:\MyFolder\
Every 10 minutes move 2000 files to C:\MyNewFolder\
Thank you!
I would use something like xcopy as recommended, however I would use the date flag to specify only copying new files. Just omit the date and it will copy only newer files.
/C Continues copying even if errors occur.
/D:m-d-y Copies files changed on or after the specified date.
If no date is given, copies only those files whose
source time is newer than the destination time.
/E Copies directories and subdirectories, including empty ones.
xcopy C:\Source Z:\Destination /C /D /E
Use Schtasks.
You may want to look here: http://technet.microsoft.com/en-us/library/bb490996.aspx