Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 04-25-2008, 11:04 AM   #1
LQ Newbie
Registered: Apr 2008
Posts: 1

Rep: Reputation: 0
Script to rename a file


I'm new to linux and need help with a script.

I want to be able to run this script from webmin

# script=dname
#parameter $1 is the existing file name
dt=`date +%y%m%d`
mv $1 $1$dt

I'm using filesystem backup to backup some files to /backup/backup.tar

problem is the file is getting over written everyday, I want to change the file name to include current date this way it wouldn't get deleted at next backup.

Can someone help
Old 04-29-2008, 09:20 AM   #2
Registered: Nov 2001
Location: Manchester, UK
Distribution: Mageia
Posts: 777

Rep: Reputation: 40
Do it in Python. Python is great for this sort of thing. It has a date library, so you can just get the day's date from it and play around naming files to your heart's content.

Python is simply fabulous and easy to learn.

Have a look at that to get basic idea then look at how to import libraries.

import time

now = time.localtime()


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
HELP! Script to RENAME/REMOVE ( ) From File NAMES!! xberetta21 Linux - Newbie 4 01-29-2008 02:10 PM
To rename files in a directory should I use Bash script or a Perl Script ? jamtech Programming 7 01-23-2008 12:25 AM
Rename script superior888 Programming 2 07-31-2006 12:53 PM
Help with script to rename shilo Slackware 10 02-04-2006 09:58 AM
File rename script jjwl89 Linux - General 1 03-14-2005 07:28 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:34 PM.

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