Home  |  Forums  |  914 Info  |  Blogs
 
914World.com - The fastest growing online 914 community!
 
Porsche, and the Porsche crest are registered trademarks of Dr. Ing. h.c. F. Porsche AG. This site is not affiliated with Porsche in any way.
Its only purpose is to provide an online forum for car enthusiasts. All other trademarks are property of their respective owners.
 

Welcome Guest ( Log In | Register )

2 Pages V  1 2 >  
Reply to this topicStart new topic
> renaming mass file extensions (HELP), in Debian Linux
bd1308
post Apr 7 2005, 11:38 AM
Post #1


Sir Post-a-lot
*****

Group: Members
Posts: 8,020
Joined: 24-January 05
From: Louisville,KY
Member No.: 3,501



I know what i want to do...i have a bizillion .php files i need to get to be .php3 files....so my logic is like this:

rm *.php *.php3

but of course, that dont work.......

please somebody help (IMG:http://www.914world.com/bbs2/html/emoticons/pray.gif)
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Root_Werks
post Apr 7 2005, 11:54 AM
Post #2


Village Idiot
*****

Group: Members
Posts: 8,315
Joined: 25-May 04
From: About 5NM from Canada
Member No.: 2,105
Region Association: Pacific Northwest



Whatch that rm command there buddy! Whoah! Slow down with the * too! You will open yourself up for massive removing of files. (IMG:http://www.914world.com/bbs2/html/emoticons/ohmy.gif)

Try mv -i so things will even prompt if they will overwrite something else. (IMG:http://www.914world.com/bbs2/html/emoticons/wink.gif)
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
bd1308
post Apr 7 2005, 11:59 AM
Post #3


Sir Post-a-lot
*****

Group: Members
Posts: 8,020
Joined: 24-January 05
From: Louisville,KY
Member No.: 3,501



QUOTE (Root_Werks @ Apr 7 2005, 11:54 AM)
Whatch that rm command there buddy!  Whoah!  Slow down with the * too!  You will open yourself up for massive removing of files.  :o

Try mv -i so things will even prompt if they will overwrite something else.  ;)

i just unzipped a dir...so deleting them isnt something i really care about...yet...is there any easy way to rename a mass of files? Just extensions now....

whoops....my brain was thinking faster than my fingers....dude i meant mv.....sorry
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
tat2dphreak
post Apr 7 2005, 12:02 PM
Post #4


stoya, stoya, stoya
*****

Group: Benefactors
Posts: 8,797
Joined: 6-June 03
From: Wylie, TX
Member No.: 792
Region Association: Southwest Region



do this: (ksh scripting):

for x in *php
do
bname = $(echo $x |cut -d. -f1)
cp $x ${bname}.php3
done


then verify everything lookas as it should and mv the old php files into a temp directory to make sure the functionality still works
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
bd1308
post Apr 7 2005, 12:05 PM
Post #5


Sir Post-a-lot
*****

Group: Members
Posts: 8,020
Joined: 24-January 05
From: Louisville,KY
Member No.: 3,501



QUOTE (tat2dphreak @ Apr 7 2005, 12:02 PM)
do this: (ksh scripting):

for x in *php
do
bname = $(echo $x |cut -d. -f1)
cp $x ${bname}.php3
done


then verify everything lookas as it should and mv the old php files into a temp directory to make sure the functionality still works

(IMG:http://www.914world.com/bbs2/html/emoticons/huh.gif) (IMG:http://www.914world.com/bbs2/html/emoticons/type.gif)
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
tat2dphreak
post Apr 7 2005, 12:16 PM
Post #6


stoya, stoya, stoya
*****

Group: Benefactors
Posts: 8,797
Joined: 6-June 03
From: Wylie, TX
Member No.: 792
Region Association: Southwest Region



QUOTE (bd1308 @ Apr 7 2005, 01:05 PM)
QUOTE (tat2dphreak @ Apr 7 2005, 12:02 PM)
do this: (ksh scripting):

for x in *php
do
bname = $(echo $x |cut -d. -f1)
cp $x ${bname}.php3
done


then verify everything lookas as it should and mv the old php files into a temp directory to make sure the functionality still works

(IMG:http://www.914world.com/bbs2/html/emoticons/huh.gif) (IMG:http://www.914world.com/bbs2/html/emoticons/type.gif)

I use unix @ work daily... you can script a lot of things right on the command line... I use Perl (not the same perl though, file manipulation) and Korn daily... lemme know how it works for you
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
bd1308
post Apr 7 2005, 12:18 PM
Post #7


Sir Post-a-lot
*****

Group: Members
Posts: 8,020
Joined: 24-January 05
From: Louisville,KY
Member No.: 3,501



QUOTE (tat2dphreak @ Apr 7 2005, 12:16 PM)
QUOTE (bd1308 @ Apr 7 2005, 01:05 PM)
QUOTE (tat2dphreak @ Apr 7 2005, 12:02 PM)
do this: (ksh scripting):

for x in *php
do
bname = $(echo $x |cut -d. -f1)
cp $x ${bname}.php3
done


then verify everything lookas as it should and mv the old php files into a temp directory to make sure the functionality still works

(IMG:http://www.914world.com/bbs2/html/emoticons/huh.gif) (IMG:http://www.914world.com/bbs2/html/emoticons/type.gif)

I use unix @ work daily... you can script a lot of things right on the command line... I use Perl (not the same perl though, file manipulation) and Korn daily... lemme know how it works for you

well can you tell me what i need to do to enter the script in? I did something and a little ">" thing poped up....is that what i need?
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
lapuwali
post Apr 7 2005, 12:20 PM
Post #8


Not another one!
****

Group: Benefactors
Posts: 4,526
Joined: 1-March 04
From: San Mateo, CA
Member No.: 1,743



Yes, just keep typing. When you hit return after the done, it will go.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
lapuwali
post Apr 7 2005, 12:22 PM
Post #9


Not another one!
****

Group: Benefactors
Posts: 4,526
Joined: 1-March 04
From: San Mateo, CA
Member No.: 1,743



Oh, and this will copy all of those files to .php3 versions, so you need to delete the .php versions after it runs and you check things. You could skip that step by replacing the cp with mv in the next to last line. Wayne's version is the safe/paranoid version.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
bd1308
post Apr 7 2005, 12:23 PM
Post #10


Sir Post-a-lot
*****

Group: Members
Posts: 8,020
Joined: 24-January 05
From: Louisville,KY
Member No.: 3,501



tmi:/var/www/phpBB2/admin# for x in *php
> do
> bname = $(echo $x |cut -d. -f1)
> cp $x ${bname}.php3
> done
bash: bname: command not found
bash: bname: command not found
bash: bname: command not found
bash: bname: command not found
bash: bname: command not found
bash: bname: command not found
bash: bname: command not found
bash: bname: command not found
bash: bname: command not found
bash: bname: command not found
bash: bname: command not found
bash: bname: command not found
bash: bname: command not found
bash: bname: command not found
bash: bname: command not found
bash: bname: command not found
bash: bname: command not found
bash: bname: command not found
bash: bname: command not found
tmi:/var/www/phpBB2/admin#
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
tat2dphreak
post Apr 7 2005, 12:33 PM
Post #11


stoya, stoya, stoya
*****

Group: Benefactors
Posts: 8,797
Joined: 6-June 03
From: Wylie, TX
Member No.: 792
Region Association: Southwest Region



QUOTE (bd1308 @ Apr 7 2005, 01:23 PM)
QUOTE (lapuwali @ Apr 7 2005, 12:20 PM)
Yes, just keep typing.  When you hit return after the done, it will go.

well the problem is i don't know how to get that to come back up
.....I'm excited to get this to work tho!!!!

(IMG:http://www.914world.com/bbs2/html/emoticons/blink.gif)

huh?

if you hit return after the done, it will run(may take a sec, since it is copying(not moving) the files... when it's done, you'll get your prompt back
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
bd1308
post Apr 7 2005, 12:36 PM
Post #12


Sir Post-a-lot
*****

Group: Members
Posts: 8,020
Joined: 24-January 05
From: Louisville,KY
Member No.: 3,501



nevermind....it worked!!!!! yea! thank you all....now you all have to tell me hwo to learn all of this stuff
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
tat2dphreak
post Apr 7 2005, 12:41 PM
Post #13


stoya, stoya, stoya
*****

Group: Benefactors
Posts: 8,797
Joined: 6-June 03
From: Wylie, TX
Member No.: 792
Region Association: Southwest Region



QUOTE (bd1308 @ Apr 7 2005, 01:36 PM)
i didnt see that you replied....i just tried it but it didnt work...i have a clip[ped section from my ssh session^^it's above

hmmm... you may not be in ksh...

do this:
which ksh (save the output)

vi a new file...

1st line: #/usr/bin/ksh ('/usr/bin/ksh' is whatever your which statment says)

then put everything else I told you in the file, make it execuable(chmod +x) and run it in the directory

User is offlineProfile CardPM
Go to the top of the page
+Quote Post
lapuwali
post Apr 7 2005, 12:45 PM
Post #14


Not another one!
****

Group: Benefactors
Posts: 4,526
Joined: 1-March 04
From: San Mateo, CA
Member No.: 1,743



QUOTE (bd1308 @ Apr 7 2005, 10:36 AM)
nevermind....it worked!!!!! yea! thank you all....now you all have to tell me hwo to learn all of this stuff

Buy a book on ksh from O'Reilly. Buy another book on Perl, also from O'Reilly. After you get started, buy one of the "Cookbook" volumes from them, and you'll find recipes for all kinds of commonly done things. Unix is Unix, for the most part, and it's been around for nearly 40 years, ksh and Perl for 20 years, so there's lots of published knowledge on how to use this stuff.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
tat2dphreak
post Apr 7 2005, 12:50 PM
Post #15


stoya, stoya, stoya
*****

Group: Benefactors
Posts: 8,797
Joined: 6-June 03
From: Wylie, TX
Member No.: 792
Region Association: Southwest Region



QUOTE (bd1308 @ Apr 7 2005, 01:36 PM)
nevermind....it worked!!!!! yea! thank you all....now you all have to tell me hwo to learn all of this stuff

cool!!!
(IMG:http://www.914world.com/bbs2/html/emoticons/beer.gif)
weird it gave that error though...


I learned it on the job...

ksh is basically a way to string together common unix commands...


"echo" "cut" "cp" are just unix commands, you can look at their man page (cut is one of the most powerful tools in string manipulation... a file name is just a string when you think about it...

the "for x in *php" basically creates an array of all the file names(strings) and loops through them 1 by 1...
from there you just "create" your new file name(string) by taking the first part of the file_name (cut command, -d means 'delimited' by what ever character you put after it, -f tells it what "field" # you want of it)...
then the cp command actually looks at the variable x as a file(instead of a string) and copies the x (original) file to the new(bname.php3) name
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
bd1308
post Apr 7 2005, 12:50 PM
Post #16


Sir Post-a-lot
*****

Group: Members
Posts: 8,020
Joined: 24-January 05
From: Louisville,KY
Member No.: 3,501



yeah, well if it weren't a bad day....my phpbb board software doesn't work...as i had hoped it would.....so back to the drawing board i suppose....what does parse error mean?
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
tat2dphreak
post Apr 7 2005, 12:54 PM
Post #17


stoya, stoya, stoya
*****

Group: Benefactors
Posts: 8,797
Joined: 6-June 03
From: Wylie, TX
Member No.: 792
Region Association: Southwest Region



QUOTE (lapuwali @ Apr 7 2005, 01:45 PM)
QUOTE (bd1308 @ Apr 7 2005, 10:36 AM)
nevermind....it worked!!!!! yea! thank you all....now you all have to tell me hwo to learn all of this stuff

Buy a book on ksh from O'Reilly. Buy another book on Perl, also from O'Reilly. After you get started, buy one of the "Cookbook" volumes from them, and you'll find recipes for all kinds of commonly done things. Unix is Unix, for the most part, and it's been around for nearly 40 years, ksh and Perl for 20 years, so there's lots of published knowledge on how to use this stuff.

O'reilly makes great refrence books... great ones... and the cookbooks are cool too,

I got a book at FRY's though, what was a "how to use korn" and another for perl... I used those basic starters WITH the O'Reilly books to learn... it also helped to know DOS...

User is offlineProfile CardPM
Go to the top of the page
+Quote Post
bd1308
post Apr 7 2005, 01:19 PM
Post #18


Sir Post-a-lot
*****

Group: Members
Posts: 8,020
Joined: 24-January 05
From: Louisville,KY
Member No.: 3,501



i'm done with linux for awhile...i have a linode, and i wanted to put phpbb2 on there but every freaking time i try to access it, i get a download window.....what in the hell am i doing wrong?
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
tat2dphreak
post Apr 7 2005, 01:26 PM
Post #19


stoya, stoya, stoya
*****

Group: Benefactors
Posts: 8,797
Joined: 6-June 03
From: Wylie, TX
Member No.: 792
Region Association: Southwest Region



QUOTE (bd1308 @ Apr 7 2005, 02:19 PM)
i'm done with linux for awhile...i have a linode, and i wanted to put phpbb2 on there but every freaking time i try to access it, i get a download window.....what in the hell am i doing wrong?

I dunno... I don't know php...

got another unix question? (IMG:http://www.914world.com/bbs2/html/emoticons/wink.gif)
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
bd1308
post Apr 7 2005, 01:28 PM
Post #20


Sir Post-a-lot
*****

Group: Members
Posts: 8,020
Joined: 24-January 05
From: Louisville,KY
Member No.: 3,501



what cool thing can i do on linux....cool random thing.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

2 Pages V  1 2 >
Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 3rd May 2024 - 04:12 PM