943,765 Members | Top Members by Rank

Ad:
Dec 18th, 2008
0

change file names

Expand Post »
hi, can someone help me?

i need a hand to get a script for a smal change.

iget this kind of structure...
20080926RIM881T.20081127.104856
20080926RIM881T.20081127.104831.done
20080926RIM881T.20081202.084408.done
20080926RIM881T.20081127.104845
20080926RIM881T.20081127.104834
20080926RIM881T.20081216.084909.done
20080926RIM950T.20080929.101124.done
20080926RIM951T.20080929.101124.done
20080926RIM952T.20080929.101125.done

i woud like to have a script to find all files with .done then i shoug change all files with .done to files without .done


like...
20080926RIM881T.20081127.104831
20080926RIM881T.20081202.084408
20080926RIM881T.20081216.084909
20080926RIM950T.20080929.101124
20080926RIM951T.20080929.101124
20080926RIM952T.20080929.101125
rgy
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rgy is offline Offline
2 posts
since Dec 2008
Dec 18th, 2008
0

Re: change file names

Click to Expand / Collapse  Quote originally posted by rgy ...
hi, can someone help me?

i need a hand to get a script for a smal change.

iget this kind of structure...
20080926RIM881T.20081127.104856
20080926RIM881T.20081127.104831.done
20080926RIM881T.20081202.084408.done
20080926RIM881T.20081127.104845
20080926RIM881T.20081127.104834
20080926RIM881T.20081216.084909.done
20080926RIM950T.20080929.101124.done
20080926RIM951T.20080929.101124.done
20080926RIM952T.20080929.101125.done

i woud like to have a script to find all files with .done then i shoug change all files with .done to files without .done


like...
20080926RIM881T.20081127.104831
20080926RIM881T.20081202.084408
20080926RIM881T.20081216.084909
20080926RIM950T.20080929.101124
20080926RIM951T.20080929.101124
20080926RIM952T.20080929.101125
i need a solution.

is it possible to change all files name from blablabla.done to blablabla without done?
rgy
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rgy is offline Offline
2 posts
since Dec 2008
Dec 18th, 2008
0

Re: change file names

ls *.done | while read line ; do mv $line $(basename $line .done) ; done
Reputation Points: 53
Solved Threads: 33
Posting Whiz in Training
bugmenot is offline Offline
224 posts
since Nov 2006
Dec 18th, 2008
1

Re: change file names

Hey there,

Just a word of practical advice. If you really "need" a solution and don't have time to wait for someone else to take of their own time to help you with your problem, try doing a search on google for something like:

Quote ...
script to remove extension from filename
and you'll have your answer straight away

Best wishes,

Mike
Reputation Points: 102
Solved Threads: 47
Posting Whiz
eggi is offline Offline
399 posts
since Oct 2007
Jan 22nd, 2009
0

Re: change file names

You can change filenames in batch by using the freeware tool "lupasrename".
I am sure it works for folder and filenames. You can select a group of files or folders and
> add or delete txt
> replace txt >>> this is the one you need !!!
> Crop left or right with N characters
> autonumber

I am not sure whether your files are all in the same folder or not. In case not, you probably will have to group them in one folder, then do the filename transformation, and then put them back in their respective original folders again.

Hope this helps
Reputation Points: 10
Solved Threads: 0
Newbie Poster
koendumont is offline Offline
1 posts
since Jan 2009
Jan 25th, 2009
0

Re: change file names

Click to Expand / Collapse  Quote originally posted by bugmenot ...
ls *.done | while read line ; do mv $line $(basename $line .done) ; done

You don't need ls.

You don't need basename (an external command).

Your script will fail if any filenames contain spaces, because you haven't quoted "$line" and "$(basename $line .done)"

Shell Scripting Syntax (Toggle Plain Text)
  1. for file in *.done
  2. do
  3. mv "$file" "${file%.done}"
  4. done
Last edited by cfajohnson; Jan 25th, 2009 at 10:09 am.
Reputation Points: 25
Solved Threads: 23
Junior Poster
cfajohnson is offline Offline
193 posts
since Dec 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Shell Scripting Forum Timeline: retrieving username and password
Next Thread in Shell Scripting Forum Timeline: noob question





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC