Forum Moderators: travelin cat
Here's what i have..
Directory name / index.html
Directory name 2 / index.html
i would like to name the file inside each directory the name of the directory...
Directory name / Directory name <-----.html file is renamed what the dirctory is named
Directory name 2/ Directory name 2 <-----.html file is renamed what the dirctory is named
I need to do this for 1800 files
Any ideas? Timster you there by chance?
Thank you so much!
Would it be easier if we did this?
Start with a text document of all the file names:
meeting0861.htm
meeting0862.htm
etc
I have 2,000 of these files and can copy the names into a Text document easily. What i want to do is duplicate a new doorway page i call it new.html And i want to duplicate this new.html file 2000 times with each duplicate being named after what is in the text document.
so new.html duplicates and is named meeting0861.htm
new.html is duplicated again and named meeting0862.html
Thank you so much
PS: Bjarne you helped me out beforeand many thanks in an awesome thread that Timster jumped in on too... I'm doing a variation of that
[webmasterworld.com...]
instead of folder would love files..
here's the old post --------
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!
cat <file> ¦ xargs -I % -R 1 cp new.html %.html Question is: do you also want these files placed into individual folders?
Look, the man pages are your friend in these cases, and even though they at first can seem a bit overwhelming you ought to be able to 'decode' them with the example solution given here.
For an introduction to the tchs shell in general look here:
[osxfaq.com...]
[macdevcenter.com...]
[macdevcenter.com...]
For very good books on Mac OS X Terminal you've got these ones:
[oreilly.com...]
[oreilly.com...]
[oreilly.com...]
[oreilly.com...]
By the way, if you've gotten that many files with a common theme you might be much better off by looking into how PHP could help you. I'm using the technique described on this page : [sitepoint.com...] to administer the content of my sites. This means, that I've got a template and then load the necessary individual pieces into this page. Thus, a sitewide update of the look-and-feel only has to be done in one place.