renaming mass file extensions (HELP), in Debian Linux |
|
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. |
|
renaming mass file extensions (HELP), in Debian Linux |
bd1308 |
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) |
Root_Werks |
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) |
bd1308 |
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 |
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 |
||
tat2dphreak |
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 |
bd1308 |
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 |
(IMG:http://www.914world.com/bbs2/html/emoticons/huh.gif) (IMG:http://www.914world.com/bbs2/html/emoticons/type.gif) |
||
tat2dphreak |
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 |
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 |
||||
bd1308 |
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 |
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? |
||||||
lapuwali |
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.
|
lapuwali |
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.
|
bd1308 |
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# |
tat2dphreak |
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 |
(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 |
||||
bd1308 |
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
|
tat2dphreak |
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 |
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 |
||
lapuwali |
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 |
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. |
||
tat2dphreak |
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 |
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 |
||
bd1308 |
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?
|
tat2dphreak |
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 |
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... |
||||
bd1308 |
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?
|
tat2dphreak |
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 |
I dunno... I don't know php... got another unix question? (IMG:http://www.914world.com/bbs2/html/emoticons/wink.gif) |
||
bd1308 |
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.
|
Lo-Fi Version | Time is now: 3rd May 2024 - 07:50 PM |
All rights reserved 914World.com © since 2002 |
914World.com is the fastest growing online 914 community! We have it all, classifieds, events, forums, vendors, parts, autocross, racing, technical articles, events calendar, newsletter, restoration, gallery, archives, history and more for your Porsche 914 ... |