Sponsored Content
Top Forums Shell Programming and Scripting Move files based on date in filename Post 302432647 by dr.house on Friday 25th of June 2010 04:01:28 PM
Old 06-25-2010
Code:
LIST=$( find $instance_hpath/db2dump -name "db2diag*.log" -mtime +30 -print )
for FILE in $LIST
do
  FYEAR=$( echo $FILE | awk -F '-' '{print $2}' )
  FMONTH=$( echo $FILE | awk -F '-' '{print $3}' )
  case $FMONTH in 
    "01") FMONTH=Jan ;;
    "02") FMONTH=Feb ;;
    "03") FMONTH=Mar ;;
    "04") FMONTH=Apr ;;
    "05") FMONTH=May ;;
    "06") FMONTH=Jun ;;
    "07") FMONTH=Jul ;;
    "08") FMONTH=Aug ;;
    "09") FMONTH=Sep ;;
    "10") FMONTH=Oct ;; 
    "11") FMONTH=Nov ;;
    "12") FMONTH=Dec ;;
  esac
  FOLDER=$FMONTH'_'$FYEAR
  mv -v $FILE $FOLDER
done


 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

how to move files into different folders based on filename

I need to move a bunch of files into folders that have the same name. I wanted to either do this with some filter command or some type of batch file that I could save that would already include all of the mv commands since I will have to do this process often. Whatever method you think is easier. ... (7 Replies)
Discussion started by: italia5
7 Replies

2. UNIX for Dummies Questions & Answers

want to move files in a dir into different directories based on the filename

I want to move the files in a dir to different dirs based on their file names. Ex: i have 4 different files with name - CTS_NONE_10476031_MRL_PFT20081215a.txt CTS_NONE_10633009_MRL_PFT20091020a.txt CTS_NONE_10345673_MRL_PFT20081215a.txt CTS_NONE_10872456_MRL_PFT20091020a.txt and the 1st... (2 Replies)
Discussion started by: Sriranga
2 Replies

3. Shell Programming and Scripting

want to move files in a dir into different directories based on the filename

I want to move the files in a dir to different dirs based on their file names. Ex: i have 4 different files with name - CTS_NONE_10476031_MRL_PFT20081215a.txt CTS_NONE_10633009_MRL_PFT20091020a.txt CTS_NONE_10345673_MRL_PFT20081215a.txt CTS_NONE_10872456_MRL_PFT20091020a.txt and the 1st... (4 Replies)
Discussion started by: Sriranga
4 Replies

4. Shell Programming and Scripting

Move file based on filename

Hi All I need a script to manipulate files based on a filename: example filename: 66600_042706.pdf the script will create a directory 66000 only if this directory is not existing. If that directory is existing it will just move the file to 66000/666000_042706.pdf in addition, i want to... (4 Replies)
Discussion started by: aemestech
4 Replies

5. Shell Programming and Scripting

Get the oldest date based on date in the filename

I am using ksh93 on Solaris. Ok, this may seem like a simple request at first. I have a directory that contains sets of files with a YYYYMMDD component to the name, along with other files of different filespecs. something like this: 20110501_1.dat 20110501_2.dat 20110501_3.dat... (2 Replies)
Discussion started by: gary_w
2 Replies

6. Shell Programming and Scripting

Move all files from source to destination directory based on the filename

Move all files starting with a specific name to different directory. This shell script program should have three parameters File Name Source Directory Destination Directory User should be able to enter ‘AB_CD*' in file name parameter. In this case all the files starting with AB_CD will... (1 Reply)
Discussion started by: chetancrsp18
1 Replies

7. Shell Programming and Scripting

Move txt file to with current date appended to filename

I have multiple txt files which begin with the word "orders" in folder C:\source. I need to move the files to folder C:\dest and rename them to "process_<date>_<count>" So for example , if there are 3 files ordersa.txt , ordersb.txt and ordersc.txt in C:\source , after running the script I want... (1 Reply)
Discussion started by: johannd
1 Replies

8. UNIX for Dummies Questions & Answers

Move txt file to with current date appended to filename

I have multiple txt files which begin with the word "orders" in folder C:\source. I need to move the files to folder C:\dest and rename them to "process_<date>_<count>" So for example , if there are 3 files ordersa.txt , ordersb.txt and ordersc.txt in C:\source , after running the script I want... (7 Replies)
Discussion started by: johannd
7 Replies

9. Shell Programming and Scripting

Move files from one directory to another based on creation/modification date

Hi All, Really stuck up with a requirement where I need to move a file (Lets say date_Employee.txt--the date will have different date values like 20120612/20120613 etc) from one directory to another based on creation/modification dates. While visiting couple of posts, i could see we can... (3 Replies)
Discussion started by: dsfreddie
3 Replies
DateTime::Locale::en_BE(3)				User Contributed Perl Documentation				DateTime::Locale::en_BE(3)

NAME
DateTime::Locale::en_BE SYNOPSIS
use DateTime; my $dt = DateTime->now( locale => 'en_BE' ); print $dt->month_name(); DESCRIPTION
This is the DateTime locale package for English Belgium. DATA
This locale inherits from the DateTime::Locale::en locale. It contains the following data. Days Wide (format) Monday Tuesday Wednesday Thursday Friday Saturday Sunday Abbreviated (format) Mon Tue Wed Thu Fri Sat Sun Narrow (format) M T W T F S S Wide (stand-alone) Monday Tuesday Wednesday Thursday Friday Saturday Sunday Abbreviated (stand-alone) Mon Tue Wed Thu Fri Sat Sun Narrow (stand-alone) M T W T F S S Months Wide (format) January February March April May June July August September October November December Abbreviated (format) Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Narrow (format) J F M A M J J A S O N D Wide (stand-alone) January February March April May June July August September October November December Abbreviated (stand-alone) Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Narrow (stand-alone) J F M A M J J A S O N D Quarters Wide (format) 1st quarter 2nd quarter 3rd quarter 4th quarter Abbreviated (format) Q1 Q2 Q3 Q4 Narrow (format) 1 2 3 4 Wide (stand-alone) 1st quarter 2nd quarter 3rd quarter 4th quarter Abbreviated (stand-alone) Q1 Q2 Q3 Q4 Narrow (stand-alone) 1 2 3 4 Eras Wide Before Christ Anno Domini Abbreviated BC AD Narrow B A Date Formats Full 2008-02-05T18:30:30 = Tuesday 5 February 2008 1995-12-22T09:05:02 = Friday 22 December 1995 -0010-09-15T04:44:23 = Saturday 15 September -10 Long 2008-02-05T18:30:30 = 5 Feb 2008 1995-12-22T09:05:02 = 22 Dec 1995 -0010-09-15T04:44:23 = 15 Sep -10 Medium 2008-02-05T18:30:30 = 05 Feb 2008 1995-12-22T09:05:02 = 22 Dec 1995 -0010-09-15T04:44:23 = 15 Sep -10 Short 2008-02-05T18:30:30 = 05/02/08 1995-12-22T09:05:02 = 22/12/95 -0010-09-15T04:44:23 = 15/09/-10 Default 2008-02-05T18:30:30 = 05 Feb 2008 1995-12-22T09:05:02 = 22 Dec 1995 -0010-09-15T04:44:23 = 15 Sep -10 Time Formats Full 2008-02-05T18:30:30 = 18 h 30 min 30 s UTC 1995-12-22T09:05:02 = 09 h 05 min 02 s UTC -0010-09-15T04:44:23 = 04 h 44 min 23 s UTC Long 2008-02-05T18:30:30 = 18:30:30 UTC 1995-12-22T09:05:02 = 09:05:02 UTC -0010-09-15T04:44:23 = 04:44:23 UTC Medium 2008-02-05T18:30:30 = 18:30:30 1995-12-22T09:05:02 = 09:05:02 -0010-09-15T04:44:23 = 04:44:23 Short 2008-02-05T18:30:30 = 18:30 1995-12-22T09:05:02 = 09:05 -0010-09-15T04:44:23 = 04:44 Default 2008-02-05T18:30:30 = 18:30:30 1995-12-22T09:05:02 = 09:05:02 -0010-09-15T04:44:23 = 04:44:23 Datetime Formats Full 2008-02-05T18:30:30 = Tuesday 5 February 2008 18 h 30 min 30 s UTC 1995-12-22T09:05:02 = Friday 22 December 1995 09 h 05 min 02 s UTC -0010-09-15T04:44:23 = Saturday 15 September -10 04 h 44 min 23 s UTC Long 2008-02-05T18:30:30 = 5 Feb 2008 18:30:30 UTC 1995-12-22T09:05:02 = 22 Dec 1995 09:05:02 UTC -0010-09-15T04:44:23 = 15 Sep -10 04:44:23 UTC Medium 2008-02-05T18:30:30 = 05 Feb 2008 18:30:30 1995-12-22T09:05:02 = 22 Dec 1995 09:05:02 -0010-09-15T04:44:23 = 15 Sep -10 04:44:23 Short 2008-02-05T18:30:30 = 05/02/08 18:30 1995-12-22T09:05:02 = 22/12/95 09:05 -0010-09-15T04:44:23 = 15/09/-10 04:44 Default 2008-02-05T18:30:30 = 05 Feb 2008 18:30:30 1995-12-22T09:05:02 = 22 Dec 1995 09:05:02 -0010-09-15T04:44:23 = 15 Sep -10 04:44:23 Available Formats d (d) 2008-02-05T18:30:30 = 5 1995-12-22T09:05:02 = 22 -0010-09-15T04:44:23 = 15 EEEd (d EEE) 2008-02-05T18:30:30 = 5 Tue 1995-12-22T09:05:02 = 22 Fri -0010-09-15T04:44:23 = 15 Sat Hm (H:mm) 2008-02-05T18:30:30 = 18:30 1995-12-22T09:05:02 = 9:05 -0010-09-15T04:44:23 = 4:44 hm (h:mm a) 2008-02-05T18:30:30 = 6:30 PM 1995-12-22T09:05:02 = 9:05 AM -0010-09-15T04:44:23 = 4:44 AM Hms (H:mm:ss) 2008-02-05T18:30:30 = 18:30:30 1995-12-22T09:05:02 = 9:05:02 -0010-09-15T04:44:23 = 4:44:23 hms (h:mm:ss a) 2008-02-05T18:30:30 = 6:30:30 PM 1995-12-22T09:05:02 = 9:05:02 AM -0010-09-15T04:44:23 = 4:44:23 AM M (L) 2008-02-05T18:30:30 = 2 1995-12-22T09:05:02 = 12 -0010-09-15T04:44:23 = 9 Md (M/d) 2008-02-05T18:30:30 = 2/5 1995-12-22T09:05:02 = 12/22 -0010-09-15T04:44:23 = 9/15 MEd (E, M/d) 2008-02-05T18:30:30 = Tue, 2/5 1995-12-22T09:05:02 = Fri, 12/22 -0010-09-15T04:44:23 = Sat, 9/15 MMdd (dd/MM) 2008-02-05T18:30:30 = 05/02 1995-12-22T09:05:02 = 22/12 -0010-09-15T04:44:23 = 15/09 MMM (LLL) 2008-02-05T18:30:30 = Feb 1995-12-22T09:05:02 = Dec -0010-09-15T04:44:23 = Sep MMMd (MMM d) 2008-02-05T18:30:30 = Feb 5 1995-12-22T09:05:02 = Dec 22 -0010-09-15T04:44:23 = Sep 15 MMMEd (E, MMM d) 2008-02-05T18:30:30 = Tue, Feb 5 1995-12-22T09:05:02 = Fri, Dec 22 -0010-09-15T04:44:23 = Sat, Sep 15 MMMMd (MMMM d) 2008-02-05T18:30:30 = February 5 1995-12-22T09:05:02 = December 22 -0010-09-15T04:44:23 = September 15 MMMMEd (E, MMMM d) 2008-02-05T18:30:30 = Tue, February 5 1995-12-22T09:05:02 = Fri, December 22 -0010-09-15T04:44:23 = Sat, September 15 ms (mm:ss) 2008-02-05T18:30:30 = 30:30 1995-12-22T09:05:02 = 05:02 -0010-09-15T04:44:23 = 44:23 y (y) 2008-02-05T18:30:30 = 2008 1995-12-22T09:05:02 = 1995 -0010-09-15T04:44:23 = -10 yM (M/yyyy) 2008-02-05T18:30:30 = 2/2008 1995-12-22T09:05:02 = 12/1995 -0010-09-15T04:44:23 = 9/-010 yMEd (EEE, M/d/yyyy) 2008-02-05T18:30:30 = Tue, 2/5/2008 1995-12-22T09:05:02 = Fri, 12/22/1995 -0010-09-15T04:44:23 = Sat, 9/15/-010 yMMM (MMM y) 2008-02-05T18:30:30 = Feb 2008 1995-12-22T09:05:02 = Dec 1995 -0010-09-15T04:44:23 = Sep -10 yMMMEd (EEE, MMM d, y) 2008-02-05T18:30:30 = Tue, Feb 5, 2008 1995-12-22T09:05:02 = Fri, Dec 22, 1995 -0010-09-15T04:44:23 = Sat, Sep 15, -10 yMMMM (MMMM y) 2008-02-05T18:30:30 = February 2008 1995-12-22T09:05:02 = December 1995 -0010-09-15T04:44:23 = September -10 yQ (Q yyyy) 2008-02-05T18:30:30 = 1 2008 1995-12-22T09:05:02 = 4 1995 -0010-09-15T04:44:23 = 3 -010 yQQQ (QQQ y) 2008-02-05T18:30:30 = Q1 2008 1995-12-22T09:05:02 = Q4 1995 -0010-09-15T04:44:23 = Q3 -10 Miscellaneous Prefers 24 hour time? Yes Local first day of the week Monday SUPPORT
See DateTime::Locale. AUTHOR
Dave Rolsky <autarch@urth.org> COPYRIGHT
Copyright (c) 2008 David Rolsky. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. This module was generated from data provided by the CLDR project, see the LICENSE.cldr in this distribution for details on the CLDR data's license. perl v5.18.2 2017-10-06 DateTime::Locale::en_BE(3)
All times are GMT -4. The time now is 05:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy