ksh shell script to add date (YYYYMMDDHHMISS) to all .txt files in a folder


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ksh shell script to add date (YYYYMMDDHHMISS) to all .txt files in a folder
# 1  
Old 10-04-2010
ksh shell script to add date (YYYYMMDDHHMISS) to all .txt files in a folder

Everyday 15 files are written to a folder \app\where\thefiles\are\destined\CURRFOLDER

Task1:

I need to add date in YYYYMMDDHHMISS format to each of them.
Example:
File: ACCOUNT.txt
Should be updated as: ACCOUNT_20101005175059.txt

Task 2:

After I update the files, they need to be

1. FTP 'd to a WINDOWS file share;

Task 3:

2. Moved to a different folder (ARCH_FOLDER) from CURRFOLDER.

Can someone please give me complete ksh shellscripts for each of the tasks.
# 2  
Old 10-04-2010
Quote:
Originally Posted by Duminix;302459424Everyday 15 files are written to a folder \app\where\thefiles\are\destined\CURRFOLDER

[B
Task1:[/B]

I need to add date in YYYYMMDDHHMISS format to each of them.
Example:
File: ACCOUNT.txt
Should be updated as: ACCOUNT_20101005175059.txt

Task 2:

After I update the files, they need to be

1. FTP 'd to a WINDOWS file share;

Task 3:

2. Moved to a different folder (ARCH_FOLDER) from CURRFOLDER.

Can someone please give me complete ksh shellscripts for each of the tasks.
It's unethical to dump all your work over here and expect someone to do it for you entirely.
We are all volunteers here. You may want to consider hiring a paid Unix consultant to do your entire task for you.
Otherwise, if you have put in some effort into this, post it over here and we can chip in with suggestions.

tyler_durden
# 3  
Old 10-04-2010
This was my first post here or any forum. I just copied my email as a question.
I have never used UNIX before and will not be using it much in future either and so I was a little embarrassed to paste what I have tried.

Task 1 is what I have been searching so far and ended up with this:
#! /bin/ksh
CD /app/server/plp_share/CR_Files_Daily/
$ for file in *.txt; do
$ mv $file ${file}`date +%Y%m%d`
END

I will work on task2 and search some more .
Task 3 looked easy. So, I guess I can manage that too.
As far as your suggestion goes, I apologize to all of you who might have thought/think I'm an @$$.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

UNIX script to replace old date with current date dynamically in multiple files present in a folder

I am trying to work on a script where it is a *(star) delimited file has a multiple lines starts with RTG and 3rd column=TD8 I want to substring the date part and I want to replace with currentdate minus 15 days. Here is an example. iam using AIX server $ cat temp.txt RTG*888*TD8*20180201~... (1 Reply)
Discussion started by: Shankar455
1 Replies

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

3. Shell Programming and Scripting

Shell script to copy files from on folder to another

I am trying to copy files with specific date and name to another folder. I am very new to shell scripting so i am finding it hard to do that. see the sample code i have written below. srcdir="/media/ubuntu/CA52057F5205720D/Users/st4r8_000/Desktop/office work/26 nov"... (13 Replies)
Discussion started by: Aqeel Abbas
13 Replies

4. Shell Programming and Scripting

Shell script to compare two files of todays date and yesterday's date

hi all, How to compare two files whether they are same are not...? like i had my input files as 20141201_file.txt and 20141130_file2.txt how to compare the above files based on date .. like todays file and yesterdays file...? (4 Replies)
Discussion started by: hemanthsaikumar
4 Replies

5. UNIX for Advanced & Expert Users

Help with ksh script to list, then cp files from a user input date range

Hi, I'm quite new to ksh scripting, can someone help me with this. Requirements: I need to create a script that list the files from a user input date range. e. g. format of file: *c1*log.2012-12-22-14-00* *c1*log.2012-12-22-14-00* *c1*log.2012-12-22-14-00*... (1 Reply)
Discussion started by: chococrunch6
1 Replies

6. Shell Programming and Scripting

Shell script that lists files with different owner than the folder

Hello, I'm trying to write a script which is listing files based on different preferences, like filetype or permissions. All is fine, except for one: I want to list files in /home which has a different owner than the home directory it is in. Here is an example: /home/UserA is the directory, and... (10 Replies)
Discussion started by: Zwiebi
10 Replies

7. Shell Programming and Scripting

How to unzip files from folder in shell script (ksh)?

I have a folder (C:\shellprg\input\) containing .CSV, .zip, .gz files. 1] I want to find all .zip/.gz files from folder (C:\shellprg\input\). 2] unzip/uncompress files into the same folder (C:\shellprg\input\) through shell script. I am using below commands for unzip files, unzip <filename>... (2 Replies)
Discussion started by: Poonamol
2 Replies

8. Shell Programming and Scripting

How to Process input files from folder in shell script?

Hi, I want to process all input files available into folder (C:\ShellPrg\InputFile\) Input files are abc.CSV , XYZ.zip (zip of CSV file), PQR.gz (zip of CSV file). I want to check the extension of file, If its .zip/.gz then need to unzip the file as .CSV I want to parse line by line of... (2 Replies)
Discussion started by: Poonamol
2 Replies

9. Shell Programming and Scripting

HOW TO CHECK ONLY .C FILES EXISTS OR NOT IN A FOLDER using IF in C shell script?

Hi friends.. I hav a problem.... I dont know how to check .c files exists r not in a folder using IF in C shell script actually i tried like this if(=~ *.c) even though some .c files or there in the current folder..it is not entering int o the if control statement...... (17 Replies)
Discussion started by: p.hemadrireddy
17 Replies

10. Shell Programming and Scripting

Shell script to find out 2 last modified files in a folder..PLZ HELP!!!!!!!!!

hi all, I need to find out the last 2 modified files in a folder.There is some way by which,we can check the timestamp and find out..??please help this is urgent. Thanks in Advance Anju (3 Replies)
Discussion started by: anju
3 Replies
Login or Register to Ask a Question