![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to edit a txt file ? | RRVARMA | Shell Programming and Scripting | 4 | 05-30-2008 09:40 AM |
| edit a file using ksh | meghana | Shell Programming and Scripting | 3 | 04-16-2008 12:04 PM |
| Edit value in File | sewood | Shell Programming and Scripting | 1 | 03-18-2008 02:11 AM |
| file edit help | sentak | Shell Programming and Scripting | 10 | 11-14-2006 08:20 AM |
| Edit an ISO / dd file? | WIntellect | Filesystems, Disks and Memory | 4 | 11-20-2002 05:21 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
ok I have a list of files for example:
130-4-32.HindIII.0.ids 130-4-32.HindIII.0.ppm 130-4-32.HindIII.0.ppm.gz 130-4-33.HindIII.0.bands 130-4-33.HindIII.0.ics 130-4-33.HindIII.0.ids 130-4-33.HindIII.0.ppm 130-4-33.HindIII.0.ppm.gz 130-4-34.HindIII.0.bands 130-4-34.HindIII.0.ics 130-4-34.HindIII.0.ids 130-4-34.HindIII.0.ppm 130-4-34.HindIII.0.ppm.gz 130-4-35.HindIII.0.bands What I need is to change all names so that djd comes before the file name (as part of the name of course). I need this to be done in batch because I have a few 100 files. thanks for the help! cd |
|
||||
|
Following script targets a specific fileset (you can adjust the ls command as needed), and renames each of those with a djd prefix. Only regular files will be processed (directories etc will be ignored). If you don't want the counts, that code can be dropped. And to be more thorough, should confirm the results of the mv (can use "if mv ...").
Code:
#!/bin/sh
rcount=0
icount=0
for fname in `ls *HIND*`
do
if [ -f $fname ] ; then
mv -i $fname djd$fname
((rcount=rcount+1))
else
echo "Bypassing $fname - not a regular file"
((icount=icount+1))
fi
done
echo "file renames: $rcount ignored: $icount"
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|