Script to compare partial filenames in two folders and delete duplicates
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 results in two folders containing files with the same name except for the file extension. My goal is to run a script every x number of minutes/hours to delete the original .mpeg files if the Plex server has already optimized them. I'm familiar with crontab well enough to set the script to run periodically but cannot figure out how to create the script to compare/delete the files.
Example;
Original video files:
Optimized video files:
The script would compare files in the two directories (minus the file extensions) and delete all files in /mnt/Plex/DVR/Original/ that match. In the example above all files in /mnt/Plex/DVR/Original/ would be deleted to save space on the hard drive.
Any insight is appreciated.
Last edited by rbatte1; 01-12-2017 at 07:45 AM..
Reason: Added CODE tags
guys i need some help in writing a shell script, what i am trying to write is a shell script that can delete generated trace files my software usually generated everyday, i will give an example to make it easy to understand
root@cms-db # pwd
/pcard17/trace
root@cms-db # ls -l HSM_VERIF.TRC*... (4 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)
Hello,
i have the following problem:
there are two folders with a lot of files.
Example:
FolderA contains AAA, BBB, CCC
FolderB contains DDD, EEE, AAA
How can i via script identify AAA as duplicate in Folder B and delete it there? So that only DDD and EEE remain, in Folder B?
Thank you... (16 Replies)
Hi Folks -
I'm quite new to awk and didn't come across such issues before. The problem statement is that, I've a file with duplicate records in 3rd and 4th fields. The sample is as below:
aaaaaa|a12|45|56
abbbbaaa|a12|45|56
bbaabb|b1|51|45
bbbbbabbb|b2|51|45
aaabbbaaaa|a11|45|56
... (3 Replies)
This has been tearing my hair out.
I need to:
1: compare server1:/data/archive/ to server2:/data/archive/ (through rsync, ssh, etc)
2: filenames that don't match, get copied (scp) to server2:/data/
server1 and server2 have ssh, scp, rsync access between eachother.
Is there any option in... (3 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 there,
I am having trouble with a script I have written, which is designed to search through a directory for a header and payload file, retrieve a string from both filenames, compare this string and if it matches make a backup of the two files then move them to a different directory for... (1 Reply)
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)
Hello, my first thread here.
I've been searching and fiddling around for about a week and I cannot find a solution.:confused:
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... (5 Replies)
Hello,
How can I remove partial duplicates and manipulate text in bash using either awk, grep or sed? Thanks.
Input:
ted,"foo,bar,zoo"
john-son,"foot,ben,zoo"
bob,"bar,foot"
Expected Output:
foo,ted
bar,ted
zoo,ted
foot,john-son
ben,john-son (4 Replies)
Discussion started by: tara123
4 Replies
LEARN ABOUT CENTOS
iowatcher
iowatcher(1) General Commands Manual iowatcher(1)NAME
iowatcher - Create visualizations from blktrace results
SYNOPSIS
iowatcher OPTIONS...
DESCRIPTION
iowatcher graphs the results of a blktrace run. It can graph the result of an existing blktrace, start a new blktrace, or start a new blk-
trace and a benchmark run. It can then create an image or movie of the IO from a given trace. iowatcher can produce either SVG files or
movies in mp4 format (with ffmpeg) or ogg format (with png2theora).
OPTIONS --help Print a brief usage summary.
-d, --device <device>
Controls which device you are tracing. You can only trace one device at a time for now. It is sent directly to blktrace, and only
needed when you are making a new trace.
-D, --blktrace-destination <destination>
Destination for blktrace.
-p, --prog <program>
Program to run while blktrace is run.
-K, --keep-movie-svgs
Keep the SVG files generated for movie mode.
-t, --trace <file|directory>
Controls the name of the blktrace file. iowatcher uses a dump from blkparse, so -t tries to guess the name of the corresponding per
CPU blktrace data files if the dump file doesn't already exist. If you want more than one trace in a given graph, you can specify
-t more than once. If a directory is specified, iowatcher will use the name of the directory as the base name of the dump file and
all trace files found inside the directory will be processed.
-l, --label <label>
Sets a label in the graph for a trace file. The labels are added in the same order the trace files are added.
-m, --movie [spindle|rect]
Create a movie. The file format depends on the extension used in the -o filename.* option. If you specify an .ogv or .ogg exten-
sion, the result will be Ogg Theora video, if png2theora is available. If you use an .mp4 extension, the result will be an mp4
video if ffmpeg is available. You can use any other extension, but the end result will be an mp4. You can use --movie=spindle or
--movie=rect, which changes the style of the IO mapping.
-T, --title <title>
Set a title to be placed at the top of the graph.
-o, --output <file>
Output filename (default: trace.svg).
-r, --rolling <seconds>
Control the duration for the rolling average. iowatcher tries to smooth out bumpy graphs by averaging the current second with sec-
onds from the past. Larger numbers here give you flatter graphs.
-h, --height <height>
Set the height of each graph
-w, --width <width>
Set the width of each graph
-c, --columns <columns>
Numbers of columns in graph output
-x, --xzoom <min:max>
Limit processed time range to min:max
-y, --yzoom <min:max>
Limit processed sectors to min:max
-a, --io-plot-action <action>
Plot given action (one of Q,D,C) in IO graph
-P, --per-process-io
Distinguish between processes in IO graph
-O, --only-graph <graph>
Add a single graph to the output (see GRAPHS). By default all the graphs are included, but with -O you get only the graphs you ask
for. -O may be used more than once.
-N, --no-graph <type>
Remove a single graph from the output (see GRAPHS). This may also be used more than once.
GRAPHS
Choices for -O and -N are:
io, tput, latency, queue_depth, iops, cpu-sys, cpu-io, cpu-irq, cpu-user, cpu-soft
EXAMPLES
Generate graph from the existing trace.dump:
iowatcher -t trace.dump -o trace.svg
Skip the IO graph:
iowatcher -t trace.dump -o trace.svg -N io
Only graph tput and latency:
iowatcher -t trace.dump -o trace.svg -O tput -O latency
Generate a graph from two runs, and label them:
iowatcher -t ext4.dump -t xfs.dump -l Ext4 -l XFS -o trace.svg
Run a fio benchmark and store the trace in trace.dump, add a title to the top, use /dev/sda for blktrace:
iowatcher -d /dev/sda -t trace.dump -T 'Fio Benchmark' -p 'fio some_job_file'
Make a movie from an existing trace:
iowatcher -t trace --movie -o trace.mp4
iowatcher(1)