I have files like file1_Mod.txt, file2_Mod.txt. I want to rename the old files with the last modification date. I write the below script to rename with current date, but I donīt know how to use "date -r" to get the last modification date with the same format I have below (dd-mm-yyyy_hhmmss).
The ouput I would like is:
file1_Old_dd-mm--yyyy_hhmmss.txt
file2_Old_dd-mm--yyyy_hhmmss.txt
Script what I have so far.
May somebody help me with this issue.
I replace follow your suggestion and it works nice. Thank you for your help.
The only thing is I get errors like shown below when the file has spaces in the name.
The only way to fix this is replace spaces (" ") with underscores ("_") or is there other way using basename, each?
Hi Chubler_XL, thanks for your reply, it works now even if the file has spaces within its name, thank you.
Hi rdcwayx, thanks for your help too, I`ve tested your script and I`m not sure what is missing, I`ve made changes trying to fixit but is failing when the files has spaces in its name.
Hi I have a problem, I have a large group of archive files in a folder some are later versions of the same archive, the only difference btween them is that the archiving program we use appends the name with a code for it to keep track of in its data base, and the modification date.
I am starting... (6 Replies)
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... (1 Reply)
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)
Hi All,
I am new to scripting and am looking for some assistance setting up a script. Basically I need the script to scan a folder for the newest files and make a copy of those files, adding a month to the date stamp. I also need this script to delete the previously copied files to save space.... (4 Replies)
Hi,
I want to rename all the files (more than 100 files) in a fodler to another folder with date&time stamp.
foe eg,
file1.dat
file2.dat
file3.dat
..
to be renamed as
file1100629_16_30_15.txt (yy-mon-dd_hh_mi_ss)
file1100629_16_30_16.txt
..
so on (2 Replies)
Hi,
I was very surprised to not be able to find an answer to this question despite my best efforts in Google and elsewhere. Maybe it's a good thing as it forced me to finally become a member in this great forum that i use frequently.
Ok my question:
I want to be able to sort files inside a... (3 Replies)
hi. I need help my programing friends :p
I need to list all the files with a certain name (for example FileName) by last modification date but only the one with the last date. If there are two files with the same name and same modification date it should print the both.
For example in this set... (6 Replies)
How to copy files from a location to a directory <YYMM> based on last modification date? This will need to run daily.
I want to copy those file for May to 0905 and Jun to 0906.
Appreciate your guidance.:) Thanks.
-rw-rw-rw- 1 ttusr tgrp 4514 May 29 21:49 AB24279J.lot_a... (17 Replies)
I have few webservers logs like access.log. which would be growing everyday.
what i do everyday is, take the backup of access.log as access.log_(currentdate) and nullify the access.log.
So thought of writing a script... but stuck up in middle.
My requirement: to take the backup and nullify... (6 Replies)