LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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, 05: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, 07:28 PM   #2
jailbait
Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Wheezy, Debian Jessie
Posts: 7,589

Rep: Reputation: 187Reputation: 187
"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


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 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 02:26 PM
Script to rename directories superior88 Linux - Newbie 4 02-15-2005 11:31 PM
rename script all files in dir Longinus Linux - Newbie 8 08-02-2004 01:24 AM
Need script to rename files joe_stevensen Programming 5 12-05-2003 07:12 PM
Got a script to rename a batch of files? jamie_barrow Linux - General 1 08-08-2003 07:52 AM


All times are GMT -5. The time now is 01:02 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration