10-25-2013
Rename all Files in a UNIX Directory from one date format to another date format
Hi Unix Gurus,
I would like to rename several files in a Unix Directory . The filenames can have more than 1 underscore ( _ ) and the last underscore is always followed by a date in the format mmddyyyy. The Extension of the files can be .txt or .pdf or .xls etc and is case insensitive ie .Xls or .XLS is also possible. Now i need to convert such a file to date format which ends with yyyymmdd.
For eg E-SSS_Reporting_for_Small_Groups_10012013.xls needs to be renamed as E-SSS_Reporting_for_Small_Groups_20131001.xls
How can i accomplish this?
Appreciate your Help on this.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I have an Foxbase application that saves dates in a character field using a Unix date format.
Does anyone know what the formula is to convert back to a standard date, something that can be, I hesitate to say, understood in a Windows environment, such as Excel or Access.
cheers
peter (2 Replies)
Discussion started by: sfpoet
2 Replies
2. Shell Programming and Scripting
hi,
for reading a cobol indexed file i need to convert "mmddyy" date format to "ccyyddd" format.
i checked the datecalc and other scripts but couldnt modify them to cater to my need:(...
The datecalc gives an output which i believe is the total days till that date, but i want to convert it... (2 Replies)
Discussion started by: Bhups
2 Replies
3. UNIX for Dummies Questions & Answers
HI,
Does anyone know how the alternative way to format date to 'Jul07' in UNIX-HP . I found HP Unix does not support date -d....:(
---------------------------------------------------------------
trxStartYear=2007
mthKey0=07
trxDay=20
key=`date -d ${trxStartYear}${mthKey0}${trxDay}... (2 Replies)
Discussion started by: epall
2 Replies
4. Shell Programming and Scripting
Hi , Can any one give me what is the date format for 3 character Month all caps (MON)
when I do date +%b it will give me Sep
But I want this to be SEP (all caps) .
Thanks in advance (1 Reply)
Discussion started by: umathurumella
1 Replies
5. Shell Programming and Scripting
I have a comma delimited log file which has the date as MM/DD/YY in the 2nd column, and HH:MM:SS in the 3rd column.
I need to change the date format to YYYY-MM-DD and merge it with the the time HH:MM:SS. How will I got about this?
Sample input
02/27/09,23:52:31
02/27/09,23:52:52... (3 Replies)
Discussion started by: hazno
3 Replies
6. UNIX for Dummies Questions & Answers
I have a list of dates in the following format: mm/dd/yyyy and want to change these to the MySQL standard format: yyyy-mm-dd.
The dates in the original file may or may not be zero padded, so April is sometimes "04" and other times simply "4".
This is what I use to change the format:
sed -i '' -e... (2 Replies)
Discussion started by: figaro
2 Replies
7. Shell Programming and Scripting
Hi Guys,
Need some help. I want to use the date command in Unix and having this below format as an output. the month should be in FIRST 3 LETTERS & ALL CAPS. And the DAY should be in two digits format
DESIRED OUTPUT:
09-JUN-11
I tried to use this command below but still it does... (2 Replies)
Discussion started by: pinpe
2 Replies
8. UNIX for Dummies Questions & Answers
Not sure why this is not working. Please advice:
#!/bin/sh
DIR=`date +"%m-%d-%y"`
echo $DIR
] && mkdir $DIR (2 Replies)
Discussion started by: iaav
2 Replies
9. Shell Programming and Scripting
Hi All,
I'm new to forum good to hear all.
I stuck in converting date format in csv file using unix
csv file contains as below
,750,0000000000000000GCJR, ,06/22/2016 14:48:44
I want to convert into as below
,750,0000000000000000GCJR, ,06/22/2016 02:48:44 PM
Please reply asap..... (22 Replies)
Discussion started by: Raghureds
22 Replies
10. Shell Programming and Scripting
i try to set linux date & time in specific format but it keep giving me error
Example :
date "+%d-%m-%C%y %H:%M:%S" -d "19-01-2017 00:05:01"
or
date +"%d-%m-%C%y %H:%M:%S" -d "19-01-2017 00:05:01"
keep giving me this error :
date: invalid date ‘19-01-2017 00:05:01'
Please use CODE tags... (7 Replies)
Discussion started by: umen
7 Replies
LEARN ABOUT LINUX
prename
RENAME(1) Perl Programmers Reference Guide RENAME(1)
NAME
rename - renames multiple files
SYNOPSIS
rename [ -v ] [ -n ] [ -f ] perlexpr [ files ]
DESCRIPTION
"rename" renames the filenames supplied according to the rule specified as the first argument. The perlexpr argument is a Perl expression
which is expected to modify the $_ string in Perl for at least some of the filenames specified. If a given filename is not modified by the
expression, it will not be renamed. If no filenames are given on the command line, filenames will be read via standard input.
For example, to rename all files matching "*.bak" to strip the extension, you might say
rename 's/.bak$//' *.bak
To translate uppercase names to lower, you'd use
rename 'y/A-Z/a-z/' *
OPTIONS
-v, --verbose
Verbose: print names of files successfully renamed.
-n, --no-act
No Action: show what files would have been renamed.
-f, --force
Force: overwrite existing files.
ENVIRONMENT
No environment variables are used.
AUTHOR
Larry Wall
SEE ALSO
mv(1), perl(1)
DIAGNOSTICS
If you give an invalid Perl expression you'll get a syntax error.
BUGS
The original "rename" did not check for the existence of target filenames, so had to be used with care. I hope I've fixed that (Robin
Barker).
perl v5.12.4 2011-08-10 RENAME(1)