MV all files and append date


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting MV all files and append date
# 1  
Old 01-19-2010
MV all files and append date

All,
I am trying to setup a command that will mv all files in a directory to another location and append a filedate.

for example:

Code:
mv * /location/*'date %y%m%d'

Any help?

Last edited by vbe; 01-19-2010 at 01:59 PM.. Reason: code tags...
# 2  
Old 01-19-2010
Interesting...
Does it work?

Usually for such tasks( move multiple files and renamve them on the fly...) people use loops...
# 3  
Old 01-19-2010
Quote:
Originally Posted by vbe
Interesting...
Does it work?

Usually for such tasks( move multiple files and renamve them on the fly...) people use loops...
lol no it doesn't work, but you are right I will have to probably use a loop. I guess a
Code:
for file in /directory/*; do mv $file $file-`date +%m%d%y`; done

Works

Thanks for pointing me in the right direction

Last edited by markdjones82; 01-19-2010 at 06:43 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Append date to an executing script

This works except the date being sent to this script. Is it because I am trying to write to an executing script? Is there a better way? date '+%m-%d-%Y_%I:%M-%p'>> Send_Email.sh CONTENT="Backup to Maxtor Drive has occured." echo "Sending email." /usr/sbin/ssmtp -t << EOF To:... (1 Reply)
Discussion started by: drew77
1 Replies

2. Shell Programming and Scripting

How to append date to filename, but base it on yesterday's date?

Hello, I'd like to write a monthly archive script that archives some logs. But I'd like to do it based on yesterday's date. In other words, I'd like to schedule the script to run on the 1st day of each month, but have the archive filename include the previous month instead. Here's what I... (5 Replies)
Discussion started by: nbsparks
5 Replies

3. Shell Programming and Scripting

Delete log files content older than 30 days and append the lastest date log file date

To delete log files content older than 30 days and append the lastest date log file date in the respective logs I want to write a shell script that deletes all log files content older than 30 days and append the lastest log file date in the respective logs This is my script cd... (2 Replies)
Discussion started by: sreekumarhari
2 Replies

4. UNIX for Dummies Questions & Answers

Seperate FlatFiles and append date !

Hi everyone, I need to create a script which dynamically splits Flatfiles and append a date. Only those should be splitted if they have more than a million rows but the date should be append every time. E.g. in my folder I have 3 flat files and only 1 of them has more than a million rows. ... (3 Replies)
Discussion started by: Richardox
3 Replies

5. UNIX for Dummies Questions & Answers

append file name with date

Hi guys, I created a very basic script that moves a specified file to a directory that I have set using the mv command. What I would like to do is append the file name with the date and time. So if I was to use the script to move a file called abc.txt, the script should rename the file... (1 Reply)
Discussion started by: jjc
1 Replies

6. UNIX for Dummies Questions & Answers

How To Append Date to File Name - AIX 5.3

Hello, I am a novice user on an AIX 5.3 system. I am running some scripts via crontab and redirecting the output to a file. For example: /home/cognos/ppdev_refresh.sh > /home/cognos/ppdev_refresh.txt I want to append the system date to the file name so it becomes:... (7 Replies)
Discussion started by: Maurice Frank
7 Replies

7. Shell Programming and Scripting

append date to file

Hi I need to append date to filename.Wrote script to get the date from table ,take this date filed and append to my i/p file when call the below script.Any help should be appreciated . Exampel If call the below script a4.sh filename o/p should be filename.2008-02-29 .... (6 Replies)
Discussion started by: mohan705
6 Replies

8. Shell Programming and Scripting

Append date to a file from CRON

Hi, I am trying to append date in DAY_Mon_dd_yyyy at the end of a filename from cron. Cron entry looks as below. (script to execute) > test_file_`date +"a_%b_%d_%Y"` File name created after executing the job is test_file_ I am expecting the filename to be something like ... (8 Replies)
Discussion started by: dncs
8 Replies

9. UNIX for Dummies Questions & Answers

Append current date to filename

In C Shell programming I haven't successfully been able to append the date in the format mmddyyyy to a filename. I've tried the following: I can print out the date in the correct format: date +%x | sed ‘s/\///g I can create a variable with the filename: set newfile=changedfiles I can... (3 Replies)
Discussion started by: gigigi
3 Replies

10. UNIX for Dummies Questions & Answers

Append date to filename

What is the easiest way to append the date (year, month, day) to a filename? (5 Replies)
Discussion started by: hshapiro
5 Replies
Login or Register to Ask a Question