Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 30th, 2007, 10:07 PM   #1
acwbrat
Newbie
 
Join Date: Oct 2007
Posts: 17
Rep Power: 0 acwbrat is on a distinguished road
Lightbulb Bash File Rename and Deletion

I have written a file rename , however my code was suppose to check the input and output of the particular files being held. Also, I have written a second code that deletes the files that haven't been used in a while on a given directory. However, I thought my codes but I would like to know where I have messed up. Inquiring minds would like to know. Thanks!


#!/bin/bash

files=$(ls -1 | grep .mp3)

for x in $files
do
mv $x band_song$x
done
.....................
#!/bin/bash
for X in *.html
        do
                rm "$X";
        done
acwbrat is offline   Reply With Quote
Old Oct 30th, 2007, 11:27 PM   #2
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,730
Rep Power: 5 Sane is on a distinguished road
Re: Bash File Rename and Deletion

I haven't ever seen a single line of Bash before, but since you PM'd me, I'll give it a shot.

If you are trying to rename all of the mp3s to have the prefix "band_song", then I would have to guess this. This is a total shot in the dark though...

#!/bin/bash

for x in *.mp3
        do
                mv "$x" "band_song$x";
        done

Unless your script already worked, and you were trying to "check the input". Which you'll need to be more specific about.
Sane is offline   Reply With Quote
Old Oct 31st, 2007, 3:27 PM   #3
acwbrat
Newbie
 
Join Date: Oct 2007
Posts: 17
Rep Power: 0 acwbrat is on a distinguished road
Re: Bash File Rename and Deletion

I have tried that method and apparently it doesn't work.
acwbrat is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:42 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC