Sponsored Content
Top Forums Shell Programming and Scripting Moving files from one directory to another based on 2 date variables Post 302659341 by dsfreddie on Wednesday 20th of June 2012 06:15:15 PM
Old 06-20-2012
Hi Corona,

Thanks for your reply. This is what I am seeing in the error log,

Code:
Date_Current=20120620
+ Date_Previous=20120610
+ IFS=_
/iis_data/source/20120609_EMPLOYEE.txt /iis_data/source/20120618_EMPLOYEE.txt /iis_data/source/20120619_EMPLOYEE.txt /iis_data/source/20120622_EMPLOYEE.txt /iis_data/source/CallParam.txt /iis_data/source/convertfuntionn.txt /iis_data/source/convert.txt /iis_data/source/Copybook.txt /iis_data/source/CPMGBUSDynamicDateFile1.txt /iis_data/source/CPMG_CDPH_Approach.txt /iis_data/source/CPMGDynamicDateFile_0410.txt

Looks like it read all the files that end with *.txt. Also, doesnt seem to move the files to the destination directory.
I suspect the below code part is causing the issue,

Code:
for EMPLOYEE in `/iis_data/source/*.txt`
do
set -- $FILE
if [ "$1" ">" "$Date_Previous" ] && [ "$1" "<" "$Date_Current" ] ||
[ "$1" = "$Date_Previous" ] || [ "$1" = "$Date_Current" ]
then
echo mv "$FILE /iis_data/destination/"
fi
done


Last edited by Scrutinizer; 06-21-2012 at 02:47 PM.. Reason: code tags + code tags instead of quote tags
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Moving files based on creation date

Howdy, I'm trying to figure out how to move multiple files based on their creation date. If anyone can enlighten me it would be most appreciated!! Thanks! :D (1 Reply)
Discussion started by: dgoyea
1 Replies

2. Shell Programming and Scripting

Moving file to directory based on condition.

Can any one help me to correct following script. I have 2 directories DropZone and ProcessZone. File pattern is *VEHDESCSUM*. Finding the 'no of files' in DropZone directory using ls *VEHDESCSUM* |wc -l If DropZone has more than one file or 0 files then exit 1 If DropZone has one file then... (2 Replies)
Discussion started by: ramanagh
2 Replies

3. Shell Programming and Scripting

Sorting Files by date and moving files in date order

I need to build a k shell script that will sort files in a directory where files appear like this "XXXX_2008021213.DAT. I need to sort by date in the filename and then move files by individual date to a working folder. concatenate the files in the working folder then start a process once... (2 Replies)
Discussion started by: rebel64
2 Replies

4. Shell Programming and Scripting

Creating date directory and moving files into that directory

I have list of files named file_username_051208_025233.log. Here 051208 is the date and 025233 is the time.I have to run thousands of files daily.I want to put all the files depending on the date of running into a date directory.Suppose if we run files today they should put into 05:Dec:08... (3 Replies)
Discussion started by: ravi030
3 Replies

5. Shell Programming and Scripting

Need script to select multiple files from archive directory based on the date range

hi all, here is the description to my problem. input parameters: $date1 & $date2 based on the range i need to select the archived files from the archived directory and moved them in to working directory. can u please help me in writing the code to select the multiple files based on the... (3 Replies)
Discussion started by: bbc17484
3 Replies

6. UNIX for Dummies Questions & Answers

Moving Directories Based on Modified date

Hi, How can I move directories (and all sub directories/files) from one directory to another based on the modified date of the directory? Currently the existing structure looks like this: /public_html/media/videos/tmb/34947/image1.jpg /public_html/media/videos/tmb/34947/image2.jpg ... (0 Replies)
Discussion started by: lbargers
0 Replies

7. 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

8. UNIX for Dummies Questions & Answers

Script moving files based on date

Hi, I need a script that moves files based on date to a folder. The folder should be created based on file date. Example is : Date file name ----- -------- Oct 08 07:39 10112012_073952.xls Oct 09 07:39 10112012_073952.xls Oct 10 07:39 ... (6 Replies)
Discussion started by: rockingvj
6 Replies

9. UNIX for Dummies Questions & Answers

Unable to find files, those can be present anywhere in the directory tree,based on its creation date

Hi I am unable to find files, those are present anywhere in the same directory tree, based on the creation date. I need to find the files with their path, as I need to create them in another location and move them. I need some help with a script that may do the job. Please help (2 Replies)
Discussion started by: sam192837465
2 Replies

10. UNIX for Beginners Questions & Answers

Searching for a files based on current date directory

Hi All, I've been trying to do some recursive searching but not been very successful. Can someone please help. Scenario: I have directory structure /dir1/dir2/dir3/ 2019/ 11/ 17 18 19 20 so what I want to do is run a script and as its 2019/11/18/ today it would go and only search... (3 Replies)
Discussion started by: israr75
3 Replies
Directory::Scratch::Structured(3pm)			User Contributed Perl Documentation		       Directory::Scratch::Structured(3pm)

NAME
Directory::Scratch::Structured - creates temporary files and directories from a structured description SYNOPSIS
my %tree_structure = ( dir_1 => { subdir_1 =>{}, file_1 =>[], file_a => [], }, dir_2 => { subdir_2 => { file_22 =>[], file_2a =>[], }, file_2 =>[], file_a =>['12345'], file_b =>[], }, file_0 => [] , ) ; use Directory::Scratch::Structured qw(create_structured_tree) ; my $temporary_directory = create_structured_tree(%tree_structure) ; or use Directory::Scratch ; use Directory::Scratch::Structured qw(piggyback_directory_scratch) ; my $temporary_directory = Directory::Scratch->new; $temporary_directory->create_structured_tree(%tree_structure) ; DESCRIPTION
This module adds a create_structured_tree subroutine to the Directory::Scratch. DOCUMENTATION
I needed a subroutine to create a bunch of temporary directories and files while running tests. I used the excellent Directory::Scratch to implement such a functionality. I proposed the subroutine to the Directory::Scratch author but he preferred to implement a subroutine using an unstructured input data based on the fact that Directory::Scratch didn't use structured data. This is, IMHO, flawed design, though it may require slightly less typing. I proposed a hybrid solution to reduce the amount of subroutines and integrate the subroutine using structured input into Directory::Scratch but we didn't reach an agreement on the API. Instead I decided that I would piggyback on Directory::Scratch. You can access create_structured_tree through a subroutine or a method through a Directory::Scratch object. Whichever interface you choose, the argument to the create_structured_tree consists of tuples (hash entries). The key represents the name of the object to create in the directory. If the value is of type: ARRAY A file will be created, it's contents are the contents of the array (See Directory::Scratch) HASH A directory will be created. the element of the hash will also be , recursively, created OTHER The subroutine will croak. SUBROUTINES
/METHODS create_structured_tree use Directory::Scratch::Structured qw(create_structured_tree) ; my $temporary_directory = create_structured_tree(%tree_structure) ; my $base = $temporary_directory->base() ; Returns a default Directory::Scratch object. directory_scratch_create_structured_tree Adds create_structured_tree to Directory::Scratch when you Load Directory::Scratch::Structured with the piggyback_directory_scratch option. use Directory::Scratch ; use Directory::Scratch::Structured qw(piggyback_directory_scratch) ; my $temporary_directory = Directory::Scratch->new; $temporary_directory->create_structured_tree(%tree_structure) ; _create_structured_tree Used internally by both interfaces piggyback Used internally to piggyback Directory::Scratch. BUGS AND LIMITATIONS
None so far. AUTHOR
Khemir Nadim ibn Hamouda CPAN ID: NKH mailto:nadim@khemir.net LICENSE AND COPYRIGHT
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SUPPORT
You can find documentation for this module with the perldoc command. perldoc Directory::Scratch::Structured You can also look for information at: o AnnoCPAN: Annotated CPAN documentation <http://annocpan.org/dist/Directory-Scratch-Structured> o RT: CPAN's request tracker Please report any bugs or feature requests to L <bug-directory-scratch-structured@rt.cpan.org>. We will be notified, and then you'll automatically be notified of progress on your bug as we make changes. o Search CPAN <http://search.cpan.org/dist/Directory-Scratch-Structured> SEE ALSO
Directory::Scratch perl v5.10.1 2010-03-22 Directory::Scratch::Structured(3pm)
All times are GMT -4. The time now is 06:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy