Sponsored Content
Top Forums Shell Programming and Scripting create t a filelist with the latest file by YYYYMMDD and move to subfolder Post 302693189 by Don Cragun on Tuesday 28th of August 2012 10:36:30 PM
Old 08-28-2012
Your directions a not entirely clear, but I believe the following performs the actions you requested and verifies that each action was performed successfully.
Code:
#!/bin/ksh
# The following assumes that this script will be run in the parent directory of the
# Incoming directory.  If this script will be run while sitting in the Incoming directory,
# remove the following cd and error checking.  Otherwise, cd to an absolute pathname
# for the Incoming directory.

if ! cd Incoming
then    echo "$0": processing aborted >&2
        exit 1
fi
ls -r ABC_[0-9][0-9][0-9][0-9][01][0-9][0-3][0-9].csv|(
        if read oldest
        then    if mv $oldest Processing/
                then    echo $oldest moved to Incoming/Processing.
                        exit 0
                else    echo $oldest not moved. >&2
                        exit 2
                fi
        else    echo $0: No matching Incoming file found. >&2
                exit 3
        fi
)

Although this script uses ksh, it should also work with at least sh and bash.

Last edited by Don Cragun; 08-29-2012 at 02:14 AM..
This User Gave Thanks to Don Cragun For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Move the latest or older File from one directory to another Directory

I Need help for one requirement, I want to move the latest/Older file in the folder to another file. File have the datetimestamp in postfix. Example: Source Directory : \a destination Directory : \a\b File1 : xy_MMDDYYYYHHMM.txt (xy_032120101456.txt) File2: xy_MMDDYYYYHHMM.txt... (1 Reply)
Discussion started by: pp_ayyanar
1 Replies

2. Shell Programming and Scripting

Link multiple files from different subfolder to a new subfolder

Hi, I have the following subfolder with files: /data/a/1/xxx.txt /data/b/2/yyy.txt /data/c/3/zzz.txt And i have a set of new folders which have exactly the same structure as above but different disk without the files: /data_02/a/1/ /data_02/b/2/ /data_02/c/3/ Now i would like to... (6 Replies)
Discussion started by: total_ysf
6 Replies

3. Shell Programming and Scripting

Recursively move a subfolder to one upper level

Hi, all: My folder structure is like: What I'm expecting to realize is to have my folders look like: How to realize it? Cheers Pei (0 Replies)
Discussion started by: jiapei100
0 Replies

4. Shell Programming and Scripting

Create subfolder within folder in one command

suppose if i am checking folder g as shown below path a/b/c/d/e/f/g ,and some directory c,d,e,f,g not present then is there anyway to create directory in one command or i need to use mkdir for everyfolder (3 Replies)
Discussion started by: lalitpct
3 Replies

5. Shell Programming and Scripting

move files defined in filelist

Hi, I have a filelist named filestomove.txt. It can contain any number of files that need to be moved to a subdirectory. All the files from filelist are in the same directory as the filelist, let say it's called Folder1. All the files need to be moved to subfolder Folder1/Subfolder1. ... (1 Reply)
Discussion started by: kedrick
1 Replies

6. UNIX for Dummies Questions & Answers

Finding latest dir based on it's name (yyyymmdd)

Hi Folks, As part of my application I need to find out what the latest directory based on the name of that directory (not it's file system timestamp). Example: I have a directory which contains below directories (each of while contains files etc) 20120000/ 20120000/ latest (symbolic link to... (5 Replies)
Discussion started by: DOWD_R
5 Replies

7. Shell Programming and Scripting

Shell script to get the latest file from the file list and move

Hi, Anybody help me to write a Shell Script Get the latest file from the file list based on created and then move to the target directory. Tried with the following script: got error. A=$(ls -1dt $(find "cveit/local_ftp/reflash-parts" -type f -daystart -mtime -$dateoffset) | head... (2 Replies)
Discussion started by: saravan_an
2 Replies

8. Shell Programming and Scripting

Script to move latest zip file to another directory

Hi folks, In my application there is a job running which create a .dat file along with it zip file also at unix box location /opt/app/cvf/temp1 so in temp1 directory I have one .dat file and its zip file also. Now since this job runs every day so if a job runs today there will be two files... (5 Replies)
Discussion started by: punpun66
5 Replies

9. Shell Programming and Scripting

Request for Shell script to move files from Subfolder to Parent folder and delete sub folder

Hi Team, I am new to shell script and there is a requirement where files should be moved from Subfolder to parent folder. Eg: parent folder --> /Interface/data/test/IN Sub folder -->/Interface/data/test/IN/Invoice20180607233338 Subfolder will be always with timestamp... (6 Replies)
Discussion started by: srivarun15
6 Replies

10. Shell Programming and Scripting

How to create symlink for latest file only?

Hello, On Solaris 10, here are entries for logs in httpd.conf ErrorLog "|/export/apache/apache-2.2.17/bin/rotatelogs -l -f /var/log/apache/error_log.%Y%m%d 86400" It keeps creating daily logs with below names - -rw-r--r-- 1 root root 1016747232 Apr 5 23:59... (16 Replies)
Discussion started by: solaris_1977
16 Replies
AVINFO(1)							   User Commands							 AVINFO(1)

NAME
AVInfo - Audio/Video file information automatic extractor SYNOPSIS
avinfo [FILENAME] [OPTIONS] [TEMPLATE] [OUTPUT] avinfo [-l=FILELIST] [OPTIONS] [TEMPLATE] [OUTPUT] avinfo -l- [OPTIONS] [TEMPLATE] [OUTPUT] avinfo [--help | --version] DESCRIPTION
Extracts information from FILENAME or files in FILELIST and generates a report. OPTIONS: -f=extension forces the use of module associated with extension -l=list use filelist (use -l- for stdin) -i=ms delay between files in filelist (in ms) (/*TODO*/) -e=ext exclude an extension (do not apply associated module) -m=number max line length (0 - no restriction) -s=value for advanced tuning of modules (/*TODO*/) -v=name=value set int. variable 'name' to 'value' (text or number) External TEMPLATEs: -th=template header template (string, use without value to disable) -thf=filename get header template from a file -tb=template body template (string, use without value to disable) -tbf=filename get body template from a file -tf=template footer template (string, use without value to disable) -tff=filename get footer template from a file Built-in TEMPLATEs: --default used by default --description for creating (updating) descrpipt.ion files --list for filelist (plain text) generation --html-list for filelist (html) generation --csv-list for filelist (CSV, e.g. for Excel) --short alt. version of --default template --far "nice" formated report (for FAR Manager) (contains MS-DOS pseudographic characters) OUTPUT: -o=file file to write the report to (default is stdout) Other OPTIONS: --help prints this help page --version prints avinfo version and copyright You can use ':' instead of '=' in all OPTIONS or just omit it. TEMPLATEs use AVInfo Simple Script (A.S.S.) syntax. Examples of commands: avinfo file.ogm --raw find . -name '*.avi' -print | avinfo -l- --html-list -o=avilist.html avinfo -l:list -thf:header -tbf=body -tff=footer >report SEE ALSO
Additional documentation for AVInfo can be found in the package documentation directory. (c) George Shuklin, 2001-2004, http://shounen.ru/soft/avinfo/ This is free software. You are welcome to redistribute it under the terms and conditions of GNU General Public License. AVInfo 1.0 alpha 15 [Balalaika] April 2005 AVINFO(1)
All times are GMT -4. The time now is 08:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy