Sponsored Content
Top Forums Shell Programming and Scripting Help with detect with regex and move script Post 302989682 by Simplify on Tuesday 17th of January 2017 07:14:21 AM
Old 01-17-2017
Help with detect with regex and move script

Hi all,

I am needing some help with a script that will search for a video file by known extensions and then do a pattern search (I'm guessing via regex) and then based on a match of one type of another move the file to an assigned directory.

I would like to do this with either a shell script such as bash or python however, I want to keep it as simple and compact as possible.

Examples

I have a folder that I have downloaded video files to, they are generally a mix of mp4, mkv, avi etc. and some will be movie files of various description and other will be tv episode that will either be named like mytvshow sxxexx (as in the sxx would be season number like s01 and the exx would be episode number like e02 for example) with a video file extension.) so the file may look like the following
TV show;
mytvshow s01e02.mp4
My Movie
my movieName.mkv

So the script needs to look at the extension or use another process to determine it is a video file and then based on the naming convension move the respective video file to a defined folder like

mytvfiles moved to /home/tv
mymovefiles moved to /home/movie

Would the scripting gurus out there help me by pointing me in the right direction with some examples of what i may use and suggestions on what may be best to suit this requirement i.e python or bash or something else maybe?

Thank you in advance for any assistance offered.

Cheers,
Darren.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

how to detect my script is already running

I have a script which must not be run more than once at any given time. THis script will be scheduled to run every 20 mins as a cron job. In my script can i have logic to say if this script is already running from the previous cron, then exit. How do i go about doing that. If you describe the... (11 Replies)
Discussion started by: rmulchandani
11 Replies

2. Shell Programming and Scripting

AWK script to detect webpages from file

Hi guys I'm very new to unix and I have to create an awk script that detects webpage addresses from a file/webpage and outputs how many times each webpage was detected.e.g. if my file was: www.google.com www.facebook.com www.google.com the output should be: www.google.com x2... (2 Replies)
Discussion started by: ROFL
2 Replies

3. Shell Programming and Scripting

Help with auto-detect new files/folders then zip and move script

Hello, I need a simple script to Auto-detect new files and folders in the directory. And then I need to zip the new files and bzip2 new folders and move them out of that folder where I am detecting changes to the other folder. Remember, I need simple one. If anyone could do it fast, I may... (1 Reply)
Discussion started by: juzt1s
1 Replies

4. Shell Programming and Scripting

Detect if script starts from queue

Dear community, what I'm try to do is deny users to run a script without parameters from command bash, but the same script should run without parameters only from crontab. Example runs by crontab:*/5 * * * * /tmp/script.sh Here the normal execution starts every 5 minutes Example #1 runs by... (16 Replies)
Discussion started by: Lord Spectre
16 Replies

5. Shell Programming and Scripting

How to detect Hanged process in shell script?

I have to check daily 20 processes each day. The names are like Network1 Network2 Network3 ....... Network20. There is built in utility for doing this. Following is the command to check a single network process. check_process_status 1 If we want to check the status of Network2 then the... (6 Replies)
Discussion started by: Nakul_sh
6 Replies

6. Shell Programming and Scripting

Detect current shell inside a script

I wish to print my current shell which happens to be bash in my script check.sh more check.sh echo $0 echo `ps -p $$` But instead of printing it prints check.sh i.e the name of the script for both the commands. Can you please suggest how to print the current shell i m on inside the... (2 Replies)
Discussion started by: mohtashims
2 Replies

7. UNIX for Advanced & Expert Users

A script to detect system type

Hi forum, So I am trying to determine the OS type with the following script: #!/usr/bin/sh OStype1=`uname -s` Sunos1=SunOs if then echo "This system is Linux" exit 0 elif then echo "This system is SunOs" exit 0 elif (1 Reply)
Discussion started by: dampio
1 Replies

8. UNIX for Beginners Questions & Answers

Script to detect time drift on server

Hello there, I am not an expert in networking related stuff but I got a requirement to create UNIX script to query our Company's internal time source via NTP for time drift detect and report it when > +/- 50ms. I have been googling a lot but thought to post it in this forum to get a... (1 Reply)
Discussion started by: Green_Star
1 Replies

9. HP-UX

Script to detect time drift

Hello there, I am not an expert in networking related stuff but I got a requirement to create UNIX script to query our Company's internal time source via NTP for time drift detect and report it when > +/- 50ms. I have been googling a lot but thought to post it in this forum to get a... (17 Replies)
Discussion started by: Green_Star
17 Replies

10. Shell Programming and Scripting

How to detect url in use in a script?

Hello, I have a small script and it runs from web application in below format: pipe:///path_to_myscript.sh url1 url2 url3 myscript.sh: #!/bin/bash count=0 while do count=$((count+1)) exec 3>&1 ((ffmpeg -i $1 ...... -f mpegts pipe:1 2>/dev/null 1>&3 ) 2>&1 | \ while read LINE; do echo... (9 Replies)
Discussion started by: baris35
9 Replies
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)
All times are GMT -4. The time now is 05:24 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy