Forum Moderators: travelin cat
I have a BBedit text doc with 800 keywords:
keyword1
keyword2
etc
and i want to name 800 folders (from untitled) using these keywords. I'm not savvy enough with applescript and have not seen any programs that will do this on versiontracker.com
I need to put these 800 folders up as directories on a website...any suggestions?
Cheers!
cd <directory_where_to_create>
cat <file_of_keywords> ¦ xargs mkdir If you haven't messed around with Terminal before, the simplest way of doing this is to have both a Terminal and a Finder window open at the same time. Then, type 'cd ' (remember the [space]) in the Terminal window and subsequently drag the directory from the Finder window to the Terminal window. Same procedure for 'cat '.
If you want to know what's behind these commands, type 'man <command>' in Terminal, where <command> is any of these four: cd , cat , xargs , mkdir
I was a little confused by the paths etc, then i figured it out. In the end I simply did exactly this:
cd /Users/mboyd/newfolders
cat /Users/mboyd/keywordtext ¦ xargs mkdir
The "pipe" character was made using shift -I <- which is just under the delete key on my keyboard.
Thanks again... If I may have one more question, how can i duplicate one index.html file into each of these 800 new folders?
=)
1. Create a new file in bbedit with this content:
#!/bin/shcd ~/Desktop/newfolders
# cat ~/keywordtext ¦ xargs mkdir # Done already
# "#" at start of line means a comment, not code
for myDir in $(ls)
do cp ~/index.html ./$myDir/index.html
# Copies your file to each directory in turn
# Assumes the page you want is in your user directory,
# and is named "index.html"
done
2. Save it as "test.sh" in your main user directory.
3. Boot the Terminal
4. Enter: chmod +x test.sh
(Makes the file an executable script.)
5. Enter: ./test.sh
(Runs the script)
I'm confused by all the #... can you paste exactly what has to go in the text doc, and any comments outside of the paste. I'm just a beginner to this terminal stuff, so I can copy and paste in the terminal and obviously pick the correct directory for it to run etc, but am confused about these commands etc, so if you would be so kind to paste it like i need it - cheers
----- begin paste -----
code here
------end paste
--- comments about code...
Nevermind my last stupid post, your instructions were perfect:
step 1: I created a BBedit doc saved with Unix breaks with the following:
--- paste --
#!/bin/sh
cd /Users/mboyd/twiggy/
for myDir in $(ls)
do cp /Users/mboyd/index/index.html ./$myDir/index.html
done
---- end paste ---
Twiggy was the name of the folder that had 800 folders all named with keywords inside it (/Users/mboyd/twiggy/). I saved test.sh loose in my home directory. (/Users/mboyd/test.sh)
I then launched terminal window and did the following:
1: cd /Users/mboyd/
2: chmod +x test.sh
3: ./test.sh
And voila 800 folders all with the same index.html inside it.
Thank you!
Here's my latest:
I have a text document with 800 keywords, and now I also have 800 folders on the hard drive all named with those keywords.
I am making my own site map. I would like to either do it in BBedit (using grep?) or maybe there is a way via terminal to take each keyword (from my text file) and link it using the same keyword as the title.
I would like to turn this (my text file filled with 800 keywords):
key-word1
key-word2
keyword3
keyword4
etc
into this (i don't mind using the same text file for saving)
<A HREF="http://www.mydomain.com/key-word1/">key-word1</A>
<A HREF="http://www.mydomain.com/key-word2/">key-word2</A>
<A HREF="http://www.mydomain.com/key-word3/">keyword3</A>
<A HREF="http://www.mydomain.com/key-word4/">keyword4</A>
is there a nice way to do that in BBedit? I'm not that savvy with it.
thanks! I appreciate it! This would complete my project. What a time saver you all have been. Much gratitude to you all.
Make a copy of your keywords file and open it.
Apple-F into the Find dialog box.
Click "Start at top" and "Use GREP"
Replace: (\S+)
With: <A HREF="http://www.mydomain.com/\1/">key-word1</A>
(Replace All)
This finds groups of non-whitespace ("\s" means whitespace and "\S" is the inverse of that, the "+" means match as many in a row as possible) and replace it with the string below.
The parentheses around the \S+ says "remember me" and the \1 says "paste the string you remembered here."
It's been a whirlwind tour of the Unix inside your Mac. You may want to pick up a good book on learning the Bash shell.
instead of:
Replace: (\S+)
With: <A HREF="http://www.mydomain.com/\1/">key_word1</A>
I did:
Replace: (\S+)
With: <A HREF="http://www.mydomain.com/\1/">\1</A>
This has been a great learning experience and I will be using this stuff over and over.
Thank you so much, You have been a great Help tim!
I hate to ask, but this would really be the icing on the cake...
would you know the grep to get rid of _ underscores in the anchor titles only? not in the anchors... replace all _ with (space) for every line after "> and capitalize first letter of every word in the title
for example
<A HREF="http://www.mydomain.com/las_vegas_gambling">Las Vegas Gambling</A>
Then I am absolutely done on this project and have no more requests! Again, thank you so much for caring enough to take the time to help me, this was really an important web project i had to do. I will look for more info on the net about grepping, seems like a great thiing to know...
all the best,
Michael
Then I am absolutely done on this project and have no more requests!
Hey, anything to demonstrate the ease, elegance, and flexibiliy of a Mac!
The quick and dirty way to fix those anchors is this (with GREP on again)
In BBEdit, replace:
>(\w+)\_ With
>\1 Repeat until the underscores are all replaced.
Now to add the capitals. Select find and make sure both the GREP and the Case Sensitive boxes are checked (and probably the "Start at Top" box too). Then replace:
>(.*)(\b[a-z]) with:
>\1\U\2 You'll have to repeat this a couple times too, as many times as the maximum number of words in an anchor.