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 REDHAT
gphoto2
GPHOTO2(1)GPHOTO2(1)NAME
gphoto2 - command-line gphoto2 client
SYNOPSIS
gphoto2 [--debug] [-q | --quiet] [-v | --verbose] [-h | --help]
[--list-cameras] [--usb-usermap-script NAME]
[--print-usb-usermap] [--list-ports] [--stdout]
[--stdout-size] [--auto-detect] [--port PATH]
[--speed SPEED] [--camera MODEL] [--filename FILENAME]
[--usbid USBID] [-a | --abilities] [--folder FOLDER]
[[-R | --recurse] | --norecurse] [-l | --list-folders]
[-L | --list-files] [-m NAME | --mkdir NAME]
[-r NAME | --rmdir NAME] [-n | --num-files]
[-p RANGE | --get-file RANGE] [-P | --get-all-files]
[-t RANGE | --get-thumbnail RANGE]
[-T | --get-all-thumbnails]
[-r RANGE | --get-raw-data RANGE] [--get-all-raw-data]
[--get-audio-data RANGE] [--get-all-audio-data]
[-d RANGE | --delete-file RANGE] [-D | --delete-all-files]
[-u FILENAME | --upload-file FILENAME] [--capture-preview]
[--capture-image] [--capture-movie] [--capture-sound]
[--capture-show-info RANGE]
[--summary] [--manual] [--about] [--shell]
DESCRIPTION gphoto2(3) is a cross-platform digital camera library, and gphoto2(1) is a command-line client for it.
Where an option takes a range of files, thumbnails, or other data, they are numbered beginning at 1. A range is a comma-separated list of
numbers or spans (``first-last''). Ranges are XOR (exclusive or), so that ``1-5,3,7'' is equivalent to ``1,2,4,5,7''.
--debug
Turn on debugging.
-q, --quiet
Quiet output (default=verbose).
-v, --version
Display version and exit.
-h, --help
Display a short usage message.
--list-cameras
List supported camera models.
--usb-usermap-script NAME
Use NAME as the hotplug usb script used in the output of --print-usb-usermap. Default is "usbcam".
--print-usb-usermap
For every camera supported by your version of gphoto2, print the corresponding line for inclusion into the usb.usermap hotplug con-
fig file. The script name used in these lines is specified with the --usb-usermap-script option.
--list-ports
List supported port devices.
--stdout
Send file to stdout.
--stdout-size
Print filesize before data.
--auto-detect
List auto-detected cameras.
--port PATH
Specify port device.
--speed SPEED
Specify serial transfer speed.
--camera MODEL
Specify camera model. Most model names contain spaces: remember to enclose the name in quotes so that the shell knows it is one
parameter. For example: --camera "Kodak DC240".
--filename FILENAME
Specify a filename.
--usbid USBID
(Expert only) Override USB IDs.
-a, --abilities
Display camera abilities.
-f, --folder FOLDER
Specify camera folder (default="/").
-R, --recurse
Recursion (default for download).
--no-recurse
No recursion (default for deletion).
-l, --list-folders
List folders in folder.
-L, --list-files
List files in folder.
-m, --mkdir NAME
Create a directory.
-r, --rmdir NAME
Remove a directory.
-n, --num-files
Display number of files.
-p, --get-file RANGE
Get files given in range.
-P, --get-all-files
Get all files from folder.
-t, --get-thumbnail RANGE
Get thumbnails given in range.
-T, --get-all-thumbnails
Get all thumbnails from folder.
-r, --get-raw-data RANGE
Get raw data given in range.
--get-all-raw-data
Get all raw data from folder.
--get-audio-data RANGE
Get audio data given in range.
--get-all-audio-data
Get all audio data from folder.
--delete-files RANGE
Delete files given in range.
--delete-all-files
Delete all files in folder.
-u, --upload-file FILENAME
Upload a file to camera.
--capture-preview
Capture a quick preview.
--capture-image
Capture an image.
--capture-movie
Capture a movie.
--capture-sound
Capture an audio clip.
--show-info RANGE
Show info.
--summary
Summary of camera status.
--manual
Camera driver manual.
--about
About the camera driver.
--shell
Start the gphoto2 shell, an interactive environment. See SHELL MODE for a detailed description.
SHELL MODE
The following commands are available:
cd Change to a directory on the camera.
lcd Change to a directory on the local machine.
exit, quit, q
Exit the gphoto2 shell.
get Download the file to the current directory.
get-thumbnail
Download the thumbnail to the current directory.
get-raw
Download raw data to the current directory.
show-info
Show information.
delete Delete a file or directory.
show-exif
Show EXIF information (only if compiled with EXIF support).
help, ?
Displays command usage.
ls List the contents of the current directory on the camera.
SEE ALSO gphoto2(3), gphoto2.txt, gphoto2-cli.txt, http://www.gphoto.org/
EXAMPLES
gphoto2 --list-files
List files on camera.
gphoto2 --get-file 7-13
Get files number 7 through 13 from the list output by gphoto2 --list-files.
gphoto2 --usb-usermap-script gphoto2cam --print-usb-usermap >> /etc/hotplug/usb.usermap
Append a line to the hotplug config file /etc/hotplug/usb.usermap for every supported camera, using /etc/hotplug/usb/gphoto2cam for
setting up permissions correctly.
AUTHOR
The gPhoto2 Team.
Man page edited by Tim Waugh <twaugh@redhat.com>.
February 2002 GPHOTO2(1)