Sponsored Content
Top Forums UNIX for Dummies Questions & Answers how to add a timestamp to a filename? Post 2621 by Optimus_P on Thursday 24th of May 2001 12:35:01 PM
Old 05-24-2001
whats going on guys. below is a script i made and am just curious if there is a "time stamp" command. so i can set the timestamp in a filename.

#! /bin/ksh
#
# This scripts takes a list of files in the INDIR variable and compairs it to a list of files that are open in the same directory.
# If this list is not the same it will continue the rest of the script.
#
# INDIR = where the program writes the file
# ARCHIVEDIR = where you want to archive the files\
# where each file will get its own directoy and each file inside of that dir will get a time stamp.
# OUTDIR = where you want the files moved to for other processes to handel
# FUUSER = user to change ownership to after move ; and used in the search for open files
# FUGROUP = group to change ownership to after move
# OPENFILE = a list of open files in the INDIR
#
# by: Mike Dooley miked_1978@yahoo.com 05-17-01

INDIR="/conway_od01/drop"
ARCHIVEDIR="/conway_od01/archive_messages"
OUTDIR="/conway_od01/edi_out"
FUUSER="conwayod"
FUGROUP="foursite"
OPENFILE=`/usr/local/bin/lsof +d ${INDIR}|grep ${FUUSER}|awk -F"/" '{ print $4 }'`

if [[ -d ${INDIR} ]] ; then

cd ${INDIR}
for file in `ls` ; do
if [[ $file != ${OPENFILE} ]]; then
mkdir ${ARCHIVEDIR}/$file 1>/dev/null 2>/dev/null
cp $file ${ARCHIVEDIR}/$file/`date +%b_%e_%Y_%T`_$file
mv $file ${OUTDIR}/$file
fi
done
fi
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

add timestamp to filename

Does anyone know how to add a timestamp to a file's name extension in a shell script? Please help.. (3 Replies)
Discussion started by: walterja
3 Replies

2. Shell Programming and Scripting

How to get a filename modified by attaching modified timestamp

Hi, I want to modify a filename in AIX by attaching the last modified timestamp. I want the timestamp completely in numerical format (eg:200905081210. yr-2009, mnth - 05, date -08, hr - 12, mins - 10). For example if the filename is a.log and it was modified on April 6th 2008 at 21.00. I... (16 Replies)
Discussion started by: Ruks
16 Replies

3. Shell Programming and Scripting

Timestamp in the filename

Hi i want to replace the previous time stamp with the current timsatp at the start of the file like 20090710_113354_FT0710a.txt this one to 20091111__113354_FT0710a.txt thanks in advance (3 Replies)
Discussion started by: Reddy482
3 Replies

4. Shell Programming and Scripting

How to extract timestamp from the filename?

Hi., My file name is of the format: name_abc_20100531_142528.txt where., my timestamp is of the format: yyyymmdd_hhmmss How to extract the date strring and time string into seperate variables in the shell script, after reading the file as the input? I want to get the variables... (9 Replies)
Discussion started by: av_vinay
9 Replies

5. Shell Programming and Scripting

Remove timestamp from multiple filename

could you pls help me out in PERL i have a requirement like a.dat.<timestamp> b.dat.<timestamp> c.dat.<timestamp> can you pls help me to rename/remove timestamp a.dat b.dat c.dat Is there any way to remove timestamp alone Thanks (3 Replies)
Discussion started by: vaas
3 Replies

6. Shell Programming and Scripting

Extract date from filename and set timestamp

I have lots of files in this format: dvgrab-2003.06.29_15-30-24.mpg The numbers represents the date and time (YYYY.MM.DD_HH-MM-SS) How can I extract the dates from the filenames, and use the dates in the file timestamp? I guess this can be done by using "find", "sed" and "touch"? Can... (6 Replies)
Discussion started by: qwerty1234
6 Replies

7. Shell Programming and Scripting

Get filename with size and timestamp

Hi, Below is a directory containing links new2,list,new1. I need to get the size and timestamp for them. How do i get these details. Please help lrwxrwxrwx 1 xxx abc 11 Nov 24 17:34 new2 -> ./org1/new2 lrwxrwxrwx 1 xxx abc 11 Nov 24 17:34 list -> ./org2/list lrwxrwxrwx 1 xxx abc 10... (2 Replies)
Discussion started by: pradebban
2 Replies

8. Shell Programming and Scripting

Filename timestamp

Hi Gurus, I have different files with different timestamp and different base file name, I have to group those files based on basename and provide a unique file name for similar file names. My Directory has following files. abc_filename_20130623:00:09:00.txt... (1 Reply)
Discussion started by: user_linux
1 Replies

9. Shell Programming and Scripting

How to sort the timestamp in the filename in shell script?

originally the shellscript #ln_file_name=`echo $ld_interface_date"_"${8}".csv"` #ln_file_name=`echo 201202011527_HL_HLTM1_B04A.csv` ln_file_name="*"`echo ${7}".csv"` get_file_list_1=$log_path"tm1_file_list.gfl1" cd ${source_path} echo "Try to find any file exist in the... (10 Replies)
Discussion started by: feilhk
10 Replies

10. Shell Programming and Scripting

How can i make my cron/script to generate a log filename with timestamp in it ?

Hello Friends, I would like my script to display date timestamps in the file name for every script execution. Below is the scenario: (just for testing purpose) I scheduled a cron job, lets say it runs every 5 min and record/logs output in to a log file. 0,5,10,15,20,25,30,35,40,45,50,55 *... (5 Replies)
Discussion started by: System Admin 77
5 Replies
DH_MOVEFILES(1) 						     Debhelper							   DH_MOVEFILES(1)

NAME
dh_movefiles - move files out of debian/tmp into subpackages SYNOPSIS
dh_movefiles [debhelperoptions] [--sourcedir=dir] [-Xitem] [file...] DESCRIPTION
dh_movefiles is a debhelper program that is responsible for moving files out of debian/tmp or some other directory and into other package build directories. This may be useful if your package has a Makefile that installs everything into debian/tmp, and you need to break that up into subpackages. Note: dh_install is a much better program, and you are recommended to use it instead of dh_movefiles. FILES
debian/package.files Lists the files to be moved into a package, separated by whitespace. The filenames listed should be relative to debian/tmp/. You can also list directory names, and the whole directory will be moved. OPTIONS
--sourcedir=dir Instead of moving files out of debian/tmp (the default), this option makes it move files out of some other directory. Since the entire contents of the sourcedir is moved, specifying something like --sourcedir=/ is very unsafe, so to prevent mistakes, the sourcedir must be a relative filename; it cannot begin with a `/'. -Xitem, --exclude=item Exclude files that contain item anywhere in their filename from being installed. file ... Lists files to move. The filenames listed should be relative to debian/tmp/. You can also list directory names, and the whole directory will be moved. It is an error to list files here unless you use -p, -i, or -a to tell dh_movefiles which subpackage to put them in. NOTES
Note that files are always moved out of debian/tmp by default (even if you have instructed debhelper to use a compatibility level higher than one, which does not otherwise use debian/tmp for anything at all). The idea behind this is that the package that is being built can be told to install into debian/tmp, and then files can be moved by dh_movefiles from that directory. Any files or directories that remain are ignored, and get deleted by dh_clean later. SEE ALSO
debhelper(7) This program is a part of debhelper. AUTHOR
Joey Hess <joeyh@debian.org> 11.1.6ubuntu2 2018-05-10 DH_MOVEFILES(1)
All times are GMT -4. The time now is 01:30 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy