LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-10-2017, 07:41 AM   #16
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,318
Blog Entries: 13

Rep: Reputation: 4372Reputation: 4372Reputation: 4372Reputation: 4372Reputation: 4372Reputation: 4372Reputation: 4372Reputation: 4372Reputation: 4372Reputation: 4372Reputation: 4372

Quote:
Originally Posted by trickydba View Post
@rtmistler......I apologize I've only been on this site about 2-3 months so I'm still working to get the hang of things
To be very clear, I'm not offended in the slightest.

We really do wish to help persons to learn and enable them to help their selves.

My point was, really what I said, and that all anyone here had to go on was your original description. As pan64 also pointed out, the rename solution is flexible, I in fact use it all the time for pictures from phones or cameras to rename them in bulk to what they really should say. It is also a one-liner versus a program or script.

You do have to learn Perl terms, and I resisted, however over the years I've learned to love rename since I have my above described use for it.

In your case, you may have other needs which do not make it so helpful of an option. Best to share your final intended vision so that when we offer advice, we can tailor it to suit what your final intentions are.
 
1 members found this post helpful.
Old 01-10-2017, 07:41 AM   #17
trickydba
Member
 
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310

Original Poster
Rep: Reputation: Disabled
My issue has been solved using Mensawater's code. It didn't work at first because of a missing parenthesis. This is the code:

for file1 in $(ls *[a-z].xlsx)
do
basefile1=$(echo $file1 |awk -F. '{print $1}')
current_time=$(date "+_%m%d%Y.xlsx")

mv $file1 ${basefile1}${current_time}
done

Thank you for all the help!
 
1 members found this post helpful.
Old 01-10-2017, 07:42 AM   #18
trickydba
Member
 
Registered: Nov 2016
Location: Atlanta,Georgia
Posts: 310

Original Poster
Rep: Reputation: Disabled
@rtmistler......understood, thanks!!
 
Old 01-10-2017, 07:46 AM   #19
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 16,500

Rep: Reputation: 5536Reputation: 5536Reputation: 5536Reputation: 5536Reputation: 5536Reputation: 5536Reputation: 5536Reputation: 5536Reputation: 5536Reputation: 5536Reputation: 5536
Code:
current_time=$(date "+_%m%d%Y")
rename 's/(.*)\./$1'$current_time'/' *[a-z].xlsx
 
2 members found this post helpful.
Old 01-10-2017, 11:56 AM   #20
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668Reputation: 1668
Glad you got it resolved. Since you got my suggestion to work I'm assuming you figured out that it assumes the original file has the .xlsx extension (in answer to a question you asked above).

I fixed the missing character in above post so people in future will see it. Sorry for the omission.

If you're in Atlanta you might want check out ALE (Atlanta Linux Enthusiasts) which is the LUG (Linux User's Group) here in Atlanta. They are also on meetup.com to announced various meetings and have a fairly active mailing list.

www.ale.org.

Last edited by MensaWater; 01-10-2017 at 11:59 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Append date to existing file name? miros84 Linux - Software 8 02-13-2013 01:56 AM
Compress and append date to a file using PHP Freddy49 Programming 5 11-05-2012 01:24 PM
Help, Selinux blocking append to named.log. mysteron Linux - Security 2 07-15-2008 07:01 AM
script to change file name and append the date john_551 Linux - Software 4 08-26-2006 06:56 AM
How to append today's date in a script anjaan Programming 4 06-12-2004 08:37 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:05 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration