Sponsored Content
Top Forums Shell Programming and Scripting Script to order my video library :-) Post 302850915 by rjalex on Friday 6th of September 2013 04:47:20 AM
Old 09-06-2013
Quote:
Originally Posted by Don Cragun
Am I correct in interpreting your requirements to be:
  1. You are sitting in a directory that contains both regular files and directories.
  2. You do not want to do anything with any files in directories under the directory in which you're sitting.
  3. You want to move regular files that have a file extension (such as .flc, .mkv, .avi, .mpg, or anything else) into a new directory. (It isn't clear to me whether you want to move a regular file like "movie.mkv" to "movie.mkv/movie.mkv" or to move it to "movie/movie.mkv". Which do you want?)
  4. You do not want to move (or remove) regular files that do not have a file extension.
Is this correct? (And, if so, do you want new directory names to have the extension stripped off from the names of the files that will be moved to them?)
Sir,
despite my wobbly English you have understood everything !!!! :-)

The files to be moved into a newly created directory should belong only to a defined set of extension. All other extensions should be ignored (for example move.txt will remain where it is).

What I need is the newly created directory to be stripped of the file extension (which luckily appears always to be a dot followed by 3 letters).

This should also cover the theoretical case (I do not seem to have any) of two regular files with the same name but two different extensions (e.g. movie5.mkv and movie5.avi and they should both end up in the same movie5 directory).

I tried whipping up a find command to address the generation of the file list but I am under the impression that the command behaves DIFFERENTLY on Debian and on Mac OS (the two Unices I'm using) :-(

Thanks so much for trying to help.

---------- Post updated at 10:47 AM ---------- Previous update was at 09:17 AM ----------

I tried starting this script and have gone somewhere although still not want I want:

Code:
#!/bin/sh
find . -type f -maxdepth 1 | while read FILE
do
    DIR=$(echo $FILE | sed 's/\....$//')
    if [ ! -d "$DIR" ]
    then
                echo mkdir "$DIR"
    fi
    echo mv "$FILE" "$DIR"
done

It's not creating the directory if for example the file contains spaces, and therefore the mkdir fails

It's not selecting only the desired extensions

Ciao !

Last edited by rjalex; 09-06-2013 at 04:25 AM.. Reason: tried to express myself better
 

6 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Changing the order of columns in a script

I have the following script: (echo -n `curl http://www.example.com/scores.txt | grep mylocation`; date +%Y%m%d%H%M%S) >> myscores.txt This script works fine, except that it places the timestamp at the end of the file myscores.txt. How do add the timestamp as the first column and then a tab and... (4 Replies)
Discussion started by: figaro
4 Replies

2. Linux

USB video capture? composite, s-video, etc

does anybody have any experience with any of these composite video to usb devices on linux? usb video capture - Google Product Search would like to get one but a linux newbie and having trouble figuring out if any are ported... i've found lots of things that link to freedesktop.org DisplayLink... (1 Reply)
Discussion started by: danpaluska
1 Replies

3. UNIX for Advanced & Expert Users

Video Cards :: Video Memory Intercept and Redirect

I need a broad spectrum understanding on this subject, and any help would be greatly appreciated. First of all, as I understand it... The way the video hardware works is the CPU sends information about input and possible changes to the display, the video card receives these changes, makes the... (2 Replies)
Discussion started by: ciNG
2 Replies

4. Shell Programming and Scripting

script for remove descending order number

hi all i want to remove some descending order number example : 1 100 200 135.00 Gk_wirs 1 1 100 200 136.00 Gk_wirs 50 1 110 210 138.00 Gk_wirs 60 1 100 200 136.00 Gk_wirs 57 ----> how to remove... (6 Replies)
Discussion started by: nithyanandan
6 Replies

5. Shell Programming and Scripting

Script to solve second order (polynomial) interpolation

Currently I have awk command to do linear interpolation awk ' { P=$2 I=$1 } END { j=0; s=I; t=I for(i=m;i<=n;i++) { if(I && i>t) { j++; s=I; t=I } print i, P+(i-s)*(P-P)/(t-s) } } ' m=1 n=8 infile FILE CONTENT... (8 Replies)
Discussion started by: Tzeronone
8 Replies

6. Shell Programming and Scripting

Script Execution Order

Hi, I have two scripts which are mentioned in execute.sh more execute.sh ./script1.sh //line 1 should not return error ./script2.sh //line 2 may return error ./script2.sh //line 3 should not return error Condition: I want script1.sh to complete before starting script2.sh... (1 Reply)
Discussion started by: mohtashims
1 Replies
DH_INSTALLDEB(1)						     Debhelper							  DH_INSTALLDEB(1)

NAME
dh_installdeb - install files into the DEBIAN directory SYNOPSIS
dh_installdeb [debhelperoptions] DESCRIPTION
dh_installdeb is a debhelper program that is responsible for installing files into the DEBIAN directories in package build directories with the correct permissions. FILES
package.postinst package.preinst package.postrm package.prerm These maintainer scripts are installed into the DEBIAN directory. Inside the scripts, the token #DEBHELPER# is replaced with shell script snippets generated by other debhelper commands. package.triggers package.shlibs These control files are installed into the DEBIAN directory. package.conffiles This control file will be installed into the DEBIAN directory. In v3 compatibility mode and higher, all files in the etc/ directory in a package will automatically be flagged as conffiles by this program, so there is no need to list them manually here. package.maintscript Lines in this file correspond to dpkg-maintscript-helper(1) commands and parameters. Any shell metacharacters will be escaped, so arbitrary shell code cannot be inserted here. For example, a line such as "mv_conffile /etc/oldconffile /etc/newconffile" will insert maintainer script snippets into all maintainer scripts sufficient to move that conffile. A versioned Pre-Dependency on dpkg is needed to use dpkg-maintscript-helper(1). An appropriate Pre-Dependency is set in ${misc:Pre-Depends} ; you should make sure to put that token into an appropriate place in your debian/control file. SEE ALSO
debhelper(7) This program is a part of debhelper. AUTHOR
Joey Hess <joeyh@debian.org> 8.9.0ubuntu2.1 2012-06-12 DH_INSTALLDEB(1)
All times are GMT -4. The time now is 05:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy