LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-14-2005, 04:41 PM   #1
jjwl89
LQ Newbie
 
Registered: Dec 2004
Posts: 5

Rep: Reputation: 0
File rename script


I found plenty of shell scripts that rename the extension of a file however I need a script that, if a the file with a certain extension exists, changes the filename to a preset name and leaves the extension alone. For example if I had the file 123568.txt put into a directory, the script world then change it to file.txt. THe script would change the name to file no matter what the original file was. I want it to run every day and check to see if a file with a certain extension exists and renames it. I'm completely new to shell scripts and would appreciate any help.
 
Old 03-14-2005, 06:28 PM   #2
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,337

Rep: Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548
"I need a script that, if a the file with a certain extension exists, changes the filename to a preset name and leaves the extension alone. For example if I had the file 123568.txt put into a directory, the script world then change it to file.txt. THe script would change the name to file no matter what the original file was."

find /home/user -iname "*.txt" -exec mv {} file.txt \;

You may have to read man find to debug the command since I have not tested it.

-----------------------------
Steve Stites
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Batch Script to rename files... jamie_barrow Linux - Newbie 16 06-14-2009 01:26 PM
Script to rename directories superior88 Linux - Newbie 4 02-15-2005 10:31 PM
rename script all files in dir Longinus Linux - Newbie 8 08-02-2004 12:24 AM
Need script to rename files joe_stevensen Programming 5 12-05-2003 06:12 PM
Got a script to rename a batch of files? jamie_barrow Linux - General 1 08-08-2003 06:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:16 PM.

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