Script to compare files in 2 folders and delete the large file
Hello, my first thread here.
I've been searching and fiddling around for about a week and I cannot find a solution.
I have been converting all of my home videos to HEVC and sometimes the files end up smaller and sometimes they don't. I am currently comparing all the video files manually and it takes up quite a bit of time.
I was wondering if there is a script that can check the 2 folders and delete the larger of the 2 files and keep the smaller one.
I have the original videos in one directory and the converted in another directory. The filenames are always the same but sometimes the extensions are different.
eg. the destination output file will always have the .mkv extension but the original may have .avi, .mpg, mp4 etc. But the filenames themselves will always be the same.
What you request is certainly possible and may have been posted, al least in part, in these fora. Did you try a search with your keywords? When "fiddling around", what were your attempts, with what tools? Where did they fail, or did you get stuck?
Please become accustomed to provide decent context info of your problem.
It is always helpful to support a request with system info like OS and shell, related environment (variables, options), preferred tools, adequate (representative) sample input and desired output data and the logics connecting the two, and, if existent, system (error) messages verbatim, to avoid ambiguities and keep people from guessing.
I searched many forums before deciding to join here. I usually find a solution but this one has proven to be hard to find.
If the answer has already been posted I apologize for creating another post about it.
I am running Ubuntu 17.04 Server on my encoding machine which sits in my basement and I access it through SSH. I am thinking of utilizing diff along with a bash script to determine whether the original or re-encoded file is smaller and then have it delete the larger of the 2 files.
I got as far as playing around with diff a little bit but I am not a script writer so I have no idea how to implement what I want to do into an efficient script.
Background: I use a TV tuner card to capture OTA video files (.mpeg) and then my Plex Media Server automatically optimizes the files (transcodes for better playback) and places them in a new directory. I have another Plex Library pointing to the new location for the optimized .mp4 files. This... (2 Replies)
Hi
I am new to Linux / scripting language. I need to improve our Linux servers at work and looking to claim some space my deleting log files/ folders on a 5 day basis.
Can someone help me with creating a script to do so.
Any sample script will be helpful.:b:
Regards (2 Replies)
Hi Everyone,
I work for GE Money IVR as a DB analyst and the environment on which I work is Solaris 5.0 server and Oracle 11g.
I got a project in which I have to clean up the folders and files which are not used in DB.
I copied an existing script and edited it, dont know this is the... (5 Replies)
Hi,
I need help in shell scripting. If someone can help me, that would be great!
Problem. I want Linux Script to compare two folders and copy missing files.
Description.
I have two directories
/dir1
/dir2
I need to copy all distinct/new/unique/missing files from /dir1 and that... (1 Reply)
Hi all,
I need a script to delete a large set of files from a directory under / based on an input file and want to redirect errors into separate file.
I have already prepared a list of files in the input file.
Kndly help me.
Thanks,
Prash (36 Replies)
Greetings!
I'm looking for starting information for a shell script. Here's my scenario:
I have multiple folders(100) for example:
/www/test/applications/app1/logs
/www/test/applications/app2/logs
Within these folders there are log files files that need to be deleted after a month.
... (3 Replies)
I do not know much about shell scripting so I am at a loss here. If someone can help me, that would be great!
I have two directories
/dir1
/dir2
I need to delete all files from /dir1 and that does not have a correspondent file in /dir2. It should NOT check file suffixes in /dir2 . Why?... (20 Replies)
I have a large Filesystem on an AIX server and another one on a Red Hat box. I have syncd the two filesystems using rsysnc.
What Im looking for is a script that would compare to the two filesystems to make sure the bits match up and the number of files match up.
its around 2.8 million... (5 Replies)
Hello,
On one of my UNIX boxes, there are many folders. I'm looking for a way / command that will search for and display folder names / location / size so I can do some cleanups.
How can I do this? (8 Replies)
Hi there,
I have written a script called "compare" (see below) to make comparison between 2 files namely test_put.log and Output_A0.log
#!/bin/ksh
while read file
do
found="no"
while read line
do
echo $line | grep $file > /dev/null
if
then
echo $file found
found="yes"
break
fi... (3 Replies)