Sponsored Content
Top Forums Shell Programming and Scripting Finding & Moving Oldest File by Parsing/Sorting Date Info in File Names Post 302220037 by nikosey on Wednesday 30th of July 2008 06:38:12 PM
Old 07-30-2008
Working Script

Yes, it's working perfectly!

Here's the full script i'm using in case it's helpful for anyone else.

It has an extra line at the top to purge files in an /archive folder that are > 7 days old.

And the folder names and locations are changed a bit from what they were in my original post.

But it seems to be working nicely.

Thanks again for the help!


Code:
#!/bin/ksh
find ../archive -name *.xml -type f -mtime +7 -exec rm {} \;
PROCESSING=$(ls ../processing | head -1)
if [[ -z $PROCESSING ]];then
   INCOMING=$(ls ../incoming/*.xml | cat | tr "_" " " | awk '{print substr($3,5,4)"."substr ($3,1,4)"|"$1"_"$2"_"$3}' | sort | head -1 | cut -d"|" -f2)
   if [[ -n $INCOMING ]];then
      mv $INCOMING ../processing
   fi
fi

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Finding the oldest file

Hi:- I need help with a script I need to modify: - what's the best/easiest way to find out the oldest file in a directory and then move this file to another directory? Thanks, (5 Replies)
Discussion started by: janet
5 Replies

2. Shell Programming and Scripting

Finding the oldest file in a particular directory

Hi all, I am a newbie to scripting and I need your help regarding finding the oldest file in a particular directory. My intention is to remove that oldest file. Are there any options available with the "find" command to do this.. Thanks in advance for your help Pavan (4 Replies)
Discussion started by: pavan_movva
4 Replies

3. UNIX and Linux Applications

Finding the oldest file in a directory without ls

I am trying to determine the oldest and most recent files in a huge directory. I am using an ls -tr statement outside my find statement. The directory is too big and I am getting an "arg list too long" error. Is there something I can put in my find statement that doesn't create a list to... (2 Replies)
Discussion started by: hiyofjord
2 Replies

4. Shell Programming and Scripting

Need help in finding filesize , moving file , gzipping file

Hi , Please help with the following questions 1) how can i find size of a file ? i have written du -k $flname > s1 . Is this right ? Any other better suggeastions ? 2) how do I use mv command for moving the file ? I need the syntax with some examples 3) Command for printing the total... (1 Reply)
Discussion started by: Learning!
1 Replies

5. Shell Programming and Scripting

Parsing Log File Based on Date & Error

I'm still up trying to figure this out and it is driving me nuts. I have a log file which has a basic format of this... 2010-10-10 22:25:42 Init block 'UA Deployment Date': Dynamic refresh of repository scope variables has failed. The ODBC function has returned an error. The database... (4 Replies)
Discussion started by: k1ko
4 Replies

6. Shell Programming and Scripting

Sorting and moving file sequence with gaps

Hello, I have lots of sequentially numbered files which make up an image sequence. I'm trying to do two things with it: #1: Find gaps in the sequence and move each range of sequencial files into their own subfolder. #2: Designate a starting point (file) and move every 24th file into... (4 Replies)
Discussion started by: ex_H
4 Replies

7. Shell Programming and Scripting

Sorting file based on names

Hi I have some files in directory and the names of files are like jnhld_15233_2010-11-23 jnhld_15233_2007-10-01 jnhld_15233_2001-05-04 jnhld_15233_2011-11-11 jnhld_15233_2005-06-07 jnhld_15233_2000-04-01 ..etc How can i sort these files based on the date in the file name so that ... (4 Replies)
Discussion started by: morbid_angel
4 Replies

8. Shell Programming and Scripting

sorting file names with hyphen and underscore

Hi, I have two types of file names filename1_12345 or filename1-12345 at the same time I have second type filename2-12345 in a txt file. I am trying to write awk script that will sort these names with below pattern ALL file names like filename1_12345 and filename1-12345 will go to... (1 Reply)
Discussion started by: rider29
1 Replies

9. Shell Programming and Scripting

Moving files only by oldest file one at a time

Hi I am want to create a script where the file gets moved from the current folder to a folder transfer based on the oldest first. This script should run one file at a time using a loop. I want it as a loop because I want to do some processing while I have one file. Can anyone guide me on this? (2 Replies)
Discussion started by: chamajid
2 Replies

10. Shell Programming and Scripting

File Move & Sort by Name - Kick out Bad File Names & More

I have a dilemma, we have users who are copying files to "directory 1." These images have file names which include the year it was taken. I need to put together a script to do the following: Examine the file naming convention, ensuring it's the proper format (e.g. test-1983_filename-123.tif)... (8 Replies)
Discussion started by: Nvizn
8 Replies
fadecut(1)						      General Commands Manual							fadecut(1)

NAME
fadecut - Toolset to rip audiostreams, cut, fade in/out and tag the resulting audiofiles SYNOPSIS
fadecut -p <profile> [ OPTIONS ] DESCRIPTION
fadecut is a script to rip audio files from a livestream (using streamripper) and to process them automatically. Beginning and ending fo the audio files will be cut and faded in/out. So logos and advertising of radio stations will be automatically removed. In streaming mode fadecut is ripping audio files using streamripper. The downloaded audio files are cutted using silence detection and then faded in and out. Subsequently, the files are encoded to either ogg or mp3 and tagged with tags (title, artist, genre and comment pro- vided). In file mode fadecut is just processing already ripped audio files. An audio file which has already been processed is detected and will not be processed again. Not desired songs can be stored in a separate directory. This files are not processed anymore too. FOLDERS
fadecut is working with some standard folders. You may change them in your profile or fadecutrc done/ here you put all your songs which were already processed by fadecut and which you want to keep. See also new/ folder. dontlike/ in this folder you may put songs which you don't like. Fadecut is checking this folder before it is processing new files in the working folder. Null size files are ok. error/ whenever an error occurs while fadecut is processing a file, that file is moved to the error folder for later examining. incomplete/ this folder is created by streamripper. All not fully ripped songs are saved here. new/ processed songs are going here. Usually you may rip and process files with fadecut, they are going in to new/ folder, you listen to them and put good songs to the done/ folder. orig/ if you want to keep the original file (which is ripped by streamripper), you may use the -k option. fadecut is putting the ripped files untouched into that folder. OPTIONS
-c Create a new profile <profilename> -e Edit an existing profile <profilename> -i optional input <directory> -o optional output <directory> -k optional to keep the untouched original song in the /orig folder -d Debug: -d 0|1|2|3 (level 0 is standard, -d without number is like 1) -h Show this message -p Profile <profilename> -q Quiet -r Stream (and rip), start streamripper -v Verbose VARIABLES
STREAM_URL="http://streamurl" test ENCODING=ogg preferred destination fileformat. (ogg/mp3) GENRE="SwissPop" Processed files will get the above genre. COMMENT="Radio Swiss Pop" Processed files will get the above comment. TRIM_BEGIN=0 cut <n> seconds off the file in the beginning. TRIM_END=0 cut <n> seconds off the file at the end. FADE_IN=1 Fade in for <n> seconds. FADE_OUT=4 Fade out for <n> seconds. EXAMPLES
Create a new ripping profile fadecut -c test Edit/update profile test fadecut -e test Rip, cut and fade in-/out with profile test fadecut -p test -r Only cut and fade in-/out without ripping from livestream fadecut -p test SEE ALSO
id3v2(1), oggenc(1), sox(1), streamripper(1), lame(1) FILES
~/.fadecut/fadecutrc The main fadecut configuration file, executed with every start of fadecut ~/.fadecut/statslog.csv The statistics file ~/.fadecut/profiles The folder where all profiles are located RESOURCES
fadecut git website https://github.com/micressor/fadecut 0.1.0 fadecut(1)
All times are GMT -4. The time now is 10:30 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy