Need help to start with some file and text manipulation

Hello script mavens,
I need help with starting a script that does the following:
-within a base folder it takes an inventory (list?) of all the files (which happen to be image files).
-creates a new folder inside the base folder and calls it imagesX where X increases by one every time the script is run
-moves all the files into the images folder
-within the base folder it creates a new text file and calls it imagesX.js
-writes a "//-" into imagesX.js
-then writes the list of filenames into the imagesX.js twice, separated by an empty line, and adds a semicolon to the end of each filename and saves imagesX.js
-from a folder a level above the base folder it copies a file called index.html into the base folder and renames in indexX.html
-in indexX.html it replaces a string "replaceThis" with "imagesX.js"
The task is more complex but this would help me tremendously do the rest.
If I am asking for too much on this forum please let me know

This should get you started.
The description of how you want to write the data isn't clear, but the rest should work (untested):
property imageNum : 0 -- last used ImageNumber
-- within a base folder it takes an inventory (list?) of all the files (which happen to be image files).
-- get the folder:
set baseFolder to (choose folder)
-- now get the files within it:
tell application "Finder"
set fileList to every file of folder baseFolder as alias list
end tell
--creates a new folder inside the base folder and calls it imagesX where X increases by one every time the script is run
tell application "Finder"
set imageNum to imageNum + 1
set newImageFolder to make new folder at baseFolder with properties {name:"images" & imageNum}
-- moves all the files into the images folder
move every file of folder baseFolder to newImageFolder
--within the base folder it creates a new text file and calls it imagesX.js
set textFile to (open for access file (baseFolder as text) & "images" & imageNum & ".js" with write permission)
--writes a "//-" into imagesX.js
write "//-" to textFile
-- then writes the list of filenames into the imagesX.js twice, separated by an empty line, and adds a semicolon to the end of each filename and saves imagesX.js
-- need more info here
-- a blank line between each instance of the file name? or all file names, blank line, all file names again?
-- an example, please
close access textFile
--from a folder a level above the base folder it copies a file called index.html into the base folder
--and renames in indexX.html
--in indexX.html it replaces a string "replaceThis" with "imagesX.js"
-- the easiest way of doing this is to read the file and write a new copy with the changes - that's easier than changing it in situ:
set indexHTML to (read file "index.html" of folder (container of baseFolder))
set {oldTIDs, my text item delimiters} to {my text item delimiters, "replaceThis"}
set indexHTML to text items of indexHTML
set my text item delimiters to "imagesX.js"
set indexHTML to indexHTML as text
set my text item delimiters to oldTIDs
set indexFile to (open for access file ("index" & imageNum & ".html") with write permission)
write indexHTML to indexFile
close access indexFile
end tell

Similar Messages

  • Need help getting started with the ML505 Development Kit

    First of all, an admission...I am a newb to the FPGA world. A babe in the wilderness. I am trying to run a simple little logic design to get my feet wet. Four inputs using the WEST, CENTER, SOUTH, and EAST pushbuttons feeding two AND gates which feeds an OR gate which turns on the NORTH LED. I have tried to use the Platform Cable USB to download the project to the XCF32P Platform Flash PROM using the iMPACT software. As of yet I have been unable to get the program to run. The iMPACT program says the programming was successful but after pressing the PROG button, the DONE LED does not turn on. I've tried different settings with the Configuration Address and Mode DIP switches with no success. To anyone using the ML505, given the gear I have at my disposal, what would you recommend? What modes have you used that worked? Thanks in advance.

    Here is the latest setup I have used in trying to get my FPGA to read from the Platform FLASH PROM. Configuration Address/Mode DIP switches set to 01011001 as per "My Own Platform Image Demonstration" method in the "ML505/ML506/ML507 Getting Started Tutorial" The Platform Cable USB is plugged into the JTAG connector on the ML505. Its status LED is green. In iMPACT the Boundary Scan reveals the following chain... TDI ----- xcf32p -----xcf32p-----xc9s144x1-----xccace-----xc5vlx50t-----TDO   The same mcs file is loaded into both PROMs (xcf32p). I start the programming cycle. It completes and says "Programming Successful" I press the PROG button on the ML505 and the DONE LED does not turn on and the design does not work. With the same chain I add the bit file to the xc5vlx50t so I have the PROMs loaded with mcs files and the FPGA with the bit file. I run the program function again. "Programming successful" is again indicated. The DONE LED lights and the design works. I then press the PROG button. The DONE LED turns off and the design ceases to function. I have also tried this with only one PROM loaded with a mcs file with no success. What am I doing wrong? Am I missing something? Thanks in advance.

  • Need help for Scheduling a Spool file and FTP the file

    I have one requirement like below...
    1. Start Scheduling a job
    2. Generate a Spool file (.csv file)
    3. If Spool file generation is successful then start FTP the file
    Else End job
    4. After successful FTP process end the job.
    We need to create a log file also for this job.
    Can any body give some idea how will i proceed?
    Thanks in advance.

    Billy  Verreynne  wrote:
    BluShadow wrote:
    Chris' may be wrapped, but it includes the funky ability to query remote files directly in SQL due to it's use of pipelined functions. A feature I've also got in my own FTP package and very useful for monitoring logs on remote servers through our Apex applications. ;)Ditto - also rolled my own FTP package as doing wildcard file listing requires custom support depending on the type of FTP server you're dealing with. The text part of the responses differ (these are not RFC'ed) and makes parsing more complex than what it could have been.Yeah, the differing responses can be a pain, though fortunately they are far and few between. There was a bug in Chris' package in that it wasn't handling a two code response from a windows FTP server for one of the commands, but I emailed him and he fixed that. Not his fault, he didn't have a windows FTP server to test on at the time.
    FTP is a pretty straight forward protocol and easy to wrap a PL/SQL package around (using <i>UTL_TCP</i>).Absolutely. and the RFC details almost everthing you need to handle. It was quite quick to knock up a package, similar to the code hoek has linked to.
    I think there is a lot of common stuff that many of us do in this regard. Always wondered how well a proper GPL'ed open source project providing a PL/SQL development framework and libraries would do...I think there'd be a lot of arguments about what is the best way of doing things. :D

  • Beginner! Need help getting started with recording music.

    I am the definition of 'new' at the moment. I want to record my own music at home and I've been told that using an Apple Mac is one of the better ways to go about it at home.
    I have a number of questions, most of which have probably been asked before (apologies!) starting right from the beginning.
    1. What type of Mac would be best suited as a dedicated tool for recording music? Obviously speed and memory are big factors, but are there any other considerations here (available inputs, drivers, sound cards etc)? I'm hoping to keep the cost below AUS$3000 if possible.
    2. Do i need any other hardware for this application? (this is where you can tell how inexperienced I am haha) such as mixers etc? If I should need a mixer, is there a particular type or brand of mixer that works well with Macs?
    3. Will plugging a guitar amp into the mac improve sound quality over plugging the guitar directly into the Mac? I bought a Griggin Garage Band guitar cable a while ago to record some background music for a friend's DVD, and I found it worked well, but I'm looking for the best quality sound now.
    4. What would be the most effective software to use? I've briefly used Garage Band and found that to be simple and useful, but I've heard that there are better software packages available.
    I'm hoping to be able to record guitar, bass and vocals directly on to the Mac, and create drum tracks using samples and loops. I know how to play music but as you can tell I know very little about recording it! Any help or suggestions would be appreciated!
    Thanks..

    I would presume one line level input will suffice?
    Close, you need a Line Level AND Mic Level input since you'll want to record vocals.
    Thanks for the link to your Q&A page, I found some very useful info there.
    It's showing its age, and will hopeful get updated soon, but most of the info is good at least for a background.
    Anyway, I think I might recommend this Presonus INSPIRE over the FireBox, it'll save you about $100 and since PreSonus makes excellent equipment (and we have an active member here that uses the Inspire), I'm confident that it offers great quality.
    I think the firepod that you use looks great, but might be overkill
    I agree, the FirePod would be serious overkill for your needs. Again, an awesome interface, but you'd be paying for all those Mic PREs, and using 1. That wouldn't make sense, and since the FP isn't cheap...
    my talent and engineering knowledge is quite limited
    Then I would strongly suggest GB as the software, and then do lots of reading. The weakest link in music production is your engineering skills. Mixing and Mastering (especially the latter) are art forms. A bad engineer using a $10,000 bit of software and hardware would make a fantastic performance sound like garbage. With good engineering skills you can make a pro recording with GB.
    The learning curve with something like Logic is dramatically increased, and again, without the skills to take advantage of what it offers, your recordings are not going to sound any better. At the very least, start with GB to learn the skills of Recording/Editing/Mixing/Mastering. The "price of admission" is low enough that if in a year you find that you need a feature GB doesn't offer, your money will not have been wasted, it will have been valuable learning time.
    Hope those more specific answers help
    ~~HangTIme [Will Compute for Food] %-)>
    Note: I am an Amazon Associate, if you purchase this item via my link I will get a small commission)

  • Preview on its own start saving some files and freezes

    I was reading a book in preview and i did some highighting work in the ebook.
    Preview started saving the document(showing increasing number of file saving 2,then 3.....so on it went till 8)
    this actvity did not gave me any access to my document to scroll and study furthur and all of a sudden the fans started spining at the max speed,preview consuming at aroung 1.45gb of ram(i checked it from activity monitor)
    as a result i had to force close preview
    this proccess repeated everytime i opened the ebook(3-4 times i tried).
    Can anyone help me out of this problem or i should think of adobe pdf reader rather than the preview.
    Here is a snapshot it took while it was showing saving 2 documents

    Kindly help please
    It's quite some time I wrote this
    No replies yet :(

  • Need help on starting with OSB

    Hi , I am new to OSB. Can some body guide me how i can start working on this ?
    to be specific any books or guides which will have the practical implementations , so that its easy to understand...

    some self promotion as author of the book : OSB 11g Development Cookbook http://www.packtpub.com/oracle-service-bus-11g-development-cookbook/book
    in this book we describe recipes which have level beginners to advanced.
    So in the beginning you will learn all the basics on how to create all the resources in the osb and further on you will continue with the more advanced recipes and technics of the osb

  • Newby...need help getting started with 80g

    ok...
    with 30gb ipod video i could connect to any type of computer pc or mac and upload music...
    with the ipod classic is it one or the other...

    17 hours??! Just to do the factory restore? Or does that include repopulating an 80Gb library. Either way it still sounds excessive to me. I take it you have USB 2.0 and a broadband net connection. I'm sure I've seen some postings about moving from PC to Mac elsewhere in the forums. You might want to track these down for useful advice before commiting to such drastic action.
    Restoring will wipe the hard drive of the iPod removing all content so be sure that there is nothing you want on the iPod that you don't have backed up somewhere else before you proceed.
    tt2

  • Need Help Getting Started with New iPod

    I already had an 8g iPod, however, I just purchased a 64 on Amazon ... it was new but open box.  I hooked it into my computer and the only thing that shows on the screen is the power chord pointing up to iTunes.
    I have reinstalled iTunes, but my system will not recognize this iPod, nor can I get to any other screens on the iPod.
    Can someone please provide some direction?
    Thanks much!
    Shelli

    Start here:
    iOS: Device not recognized in iTunes for Windows
    The Users Guide is noice to have too.
    iPod touch User Guide (For iOS 5.0 Software)

  • I have a Macbook Air (july 2012) with OS X 10.8.3  installed.  I have dvds with .vob files and have Quicktime Version 10.2 (603.12).  I can't play the DVDs.  Thereare some features of QT that I like, e.g. precise frame selection and save as .png file-help

    I have a Macbook Air (july 2012) with OS X 10.8.3  installed.  I have dvds with .vob files and have Quicktime Version 10.2 (603.12).  I can't play the DVDs.  There are some features of QT that I like, e.g. precise frame selection and save as .png file-help.  Am I missing some Apple software?  I thought QT for Mountain Lion could convert the .vob files - is there some setting that I have missed?
    Any suggestions that preserves a simple workflow much appreciated.

    arthur wrote:
    Perian is here: Perian - The swiss-army knife of QuickTime® components
    Perian will be retired soon.

  • Need help to share Number/Pages file visa Mail option. Cannot do with iPad Air (iOS7)

    Need help to share Number/Pages file visa Mail option. Cannot do with iPad Air

    Oh, okay. After selecting the format I want to send, it says "creating... ". Then irrespective of the format I choose the message e.g. "creating spreadsheet" disappears, and so does the choice window (where I earlier chose Mail). I am taken back to the Numbers (or Page) where I had started from. Diavonex's note indicated that after "creating ... " stage I should be taken to an option where I can type in email address where I want to  send the  file, if I want to copy it to another address etc. I cannot arrive at that page - no matter whether I am working with Pages or Number, or which format I choose for the file to share !
    I will try to close as you have suggested and try. However, I have switched on and off several times by now, but nothing changed!
    Will look forward to any ideas to solve this !!!
    Thanks much!
    Best

  • I have tried everything I know to retrieve the iPhoto Library app.  I detest this new Photo app, which obviously wasn't designed with photographers in mind.  I desperately need help in retrieving the old app and have not been able to do it so far.

    I have tried everything I know to retrieve the iPhoto Library app.  I detest this new Photo app, which obviously wasn't designed with photographers in mind.  I desperately need help in retrieving the old app and have not been able to do it so far.  I have gone to my app folder and tried to update my iPhoto Library.  I have gone to my trash and brought it over to my desktop and still cannot use it.  Please help!

    Try this fix discovered by User photosb189:
    From Finder, hold down the option key on your keyboard and click on the Go menu at the top of the screen
    Select Library from the drop down menu
    Then navigate to Application Support > iLifeAssetManagement > assets
    Right click on the 'sub' folder and choose Compress
    Drag the resulting zip file to your Desktop (as a backup)
    Go to your System Preferences and choose iCloud
    Turn OFF the iCloud Photos option
    Go back to Library > Application Support and DELETE the iLifeAssetManagement folder
    Now, in System Preferences, turn the iCloud Photos option ON
    iPhoto should now be able to launch. Give it enough time to re-download your Photo Stream content. if you are missing any of your My Photo Stream photos (more than 30 days old), unzip the sub folder on your desktop and drag that into iPhoto.

  • Macbook pro starts up but i see picture of some files and a question mark

    So I was on my laptop today and it just outta nowhere froze , the song i was listening stopped and i couldn't change the page, i could move the trackpad but nothing else.
    so i clicked on the off button and turned it off.
    then i tried to turn it on again but while loading it just stayed blank and this picture of some files and a question mark on them appeared, i have no idea what's going on.
    I turned it off again and turned it back on and the little apple appeared and it was loading but then a sign appeared like one of prohibited (the one that's a circle and has a slash across it) and idk what to do! i'm so frustrated all my school files are there and idk why this happened in the first place.
    i turned it off and just put it to charge.
    lately i've been using it a lot and i had a few things on when it froze , so im just gonna leave it off for a while but what can i do?
    how do u solve this? has anyone had this happened to their macbook pro already? i bought it just last year idk why this is happening.

    The folder and question mark means it cannot find a valid OSX Boot Volume, you need to Boot from your original install DVD (hold c at start) and then run Disc Utility from the top menu bar and run both 'Repair Disc' and 'Repair Permissions'. If it still doesn't boot from the internal hard drive then you need to boot from that install DVD again and do an archive (re)install of the operating system. (Your User data will be saved that way)

  • There are text messages that I'm having trouble deleting.  With some of my text messages, I can swipe to the left and delete ... or press and hold, get more and delete to trash can icon. But there are some where neither will work. Can't delete. Help!

    There are text messages that I'm having trouble deleting.  With some of my text messages, I can swipe to the left and delete ... or press and hold, get more and delete to trash can icon. But there are some where neither will work. Can't delete. Help!

    But once again, I do not want to lose my other texts, app progress, and photos. I could sync the photos but i would still lose the app progress and texts. I would only restore if it was the only option left, but the other space, as already stated, isnt the main concern. The main concern is those 'deleted' texts. If they go, then a good size chunk of the other space goes. I know you CAN delete texts for good. It worked fine before. All i want to know is why its not working for me now, and how to fix it.
    I also know that when you delete texts on your iphone, they get marked for deletion, however they stay on your device (thats why they show up when you search for them.) then when you sync your device with itunes, the texts marked for deletion should disappear. When i synced they didnt disappear. Thats what i need an explanation/solution for. Why the texts marked for deletion didnt get fully deleted after the sync.

  • Capitalization doesn't work as described. One can start with lower case and change to upper, but changing from upper case to any of the other options doesn't work. Is there a way around this or is this just a glitch that needs fixing?

    In Pages capitalization doesn't work as described. One can start with lower case and change to upper, but changing from upper case to any of the other options doesn't work. Is there a way around this or is this just a glitch that needs fixing?

    I think it does work as described, but the description is not very complete. Capitalization does not change any of the characters that you type; what it does is allow some of the lower case characters to display as capitals. If you copy the result and paste it as plain text, you'll see that the lower case characters are still there. It doesn't actually say anywhere that it can make capitals display as lower case, and it can't.
    The obvious way around this is to actually type what you want.
    The more powerful way is to install WordService from Devon Technologies which adds the functionality of Pages' capitalization menu as well a lot of other ones. WordService actually changes the character to the one displayed, and it works in most of the applications on your Mac.

  • I recently have ipad but before i sell it i made a back up of it and by an iphone when i put all the date on my iphone some files and software did not install is there anything i can do to recover the lost data? please help

    i recently have ipad but before i sell it i made a back up of it and by an iphone when i put all the date on my iphone some files and software did not install is there anything i can do to recover the lost data? please help

    I don't think you're on iOS 5, I think you're using iOS 6.  That's the latest version.
    Unless you've used iCloud to back up your documents, you won't be able to restore them.  And for future reference, you don't have to uninstall Pages to update your iPad anymore.  Sorry about this.

Maybe you are looking for