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
widget_calendar(n)					    widget::calendar Megawidget 					widget_calendar(n)

__________________________________________________________________________________________________________________________________________________

NAME
widget_calendar - widget::calendar Megawidget SYNOPSIS
package require Tcl 8.4 package require Tk 8.4 package require widget ?3.0? widget::calendar pathname ?options? _________________________________________________________________ DESCRIPTION
This package provides a calendar megawidget (snidget). widget::calendar pathname ?options? WIDGET OPTIONS
-command A script to evaluate when a date was selected. -dateformat The format of the date that is returned. Default: %m/%d/%Y. -firstday Set first day the week, Either sunday or monday. It defaults to monday. -font Select the font used in the widget. It defaults to Helvetica 9. -highlightcolor Selects the background color for the day that has been selected. Default: #FFCC00 -language Specify language of the calendar contents. The language is specified by abbreviations of the languge, for example: en - english, de - german ... It defaults to en. Supported languages: en, de, fr, it, es, pt, ru, sv, zh, fi -shadecolor Selects the color of the parts that have a shaded background. Default: #888888 -showpast Specify if the past shall be shown. It is a boolean value and defaults to 1. -textvariable Specifies the name of a variable whose value is linked to the entry widget's contents. Whenever the variable changes value, the widget's contents are updated, and vice versa. WIDGET COMMAND
pathname get ?what? Returns a part of the selected date or 'all'. The argument what selects the part. Valid values for what are: day, month, year and all. 'all' is the default and returns the complete date in the format given with -dateformat. DEFAULT BINDINGS
On creation of the calendar widget the following bindings are installed. o Up - Move to week before current date o Down - Move to week after current date o Left - Move to day before current date o Right - Move to day after current date o Control-Left - Move to month before current date o Control-Right - Move to month after current date o Control-Up - Move to year before current date o Control-Down - Move to year after current date EXAMPLE
package require widget::calendar ; # or widget::all set t [widget::calendar .t] pack $t -fill x -expand 1 KEYWORDS
megawidget, snit, widget widget 0.93 widget_calendar(n)
All times are GMT -4. The time now is 12:26 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy