Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6673033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:34:47+00:00 2026-05-26T03:34:47+00:00

EDIT: regulus6633 has made a script that’s a lot better than my outline below,

  • 0

EDIT: regulus6633 has made a script that’s a lot better than my outline below, it works perfectly IF you’re template file isn’t completely empty (I think this caused an error originally). Thanks!

This script is supposed to (1) copy a x.txt to a specific folder rename it to new_name, (2) open it, (3) paste “new_name” in all caps, and (4) insert “:” followed by return & return. The first part is working, but I’m having trouble figuring out (2), (3) and (4). The code I’ve written so far is pasted below.

 tell application "Finder"
        display dialog "new_name_dialogue" default answer " "
        set new_name to (text returned of result)
        set Selected_Finder_Item to (folder of the front window) as text
        duplicate file "Q:x:7:n7:GTD scripting:template folder:x.txt" to "Q:X:7:SI:SIAG1"
        set Path_Of_X to "Q:X:7:SI:SIAG1:" & "x.txt" as string
        set name of file Path_Of_X to (new_name as text) & ".txt"
#[something that let's me open the file is needed here]
#[something that pastes "new_name" & ":" in ALL CAPS]
#[something that inserts two lineshifts]
    end tell
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T03:34:48+00:00Added an answer on May 26, 2026 at 3:34 am

    In general since you’re dealing with a txt file, you do not need to “open” the file in an application and paste in text. We can read and write to text files directly from applescript. As such we read in the text from the template file, add whatever text we want to that, and then write the new text to a new file. If you then want to open and view the new file you can do that after. I did that in the “TextEdit” section of the code.

    You can see at the end of the script I have subroutines to write a text file and also to change the file name to CAPS. So try the following…

    -- initial variables
    set templateFile to "Q:x:7:n7:GTD scripting:template folder:x.txt"
    set copyFolder to "Q:X:7:SI:SIAG1:" -- notice this path ends in ":" because it's a folder
    
    -- get the new name
    display dialog "new_name_dialogue" default answer ""
    set newName to (text returned of result)
    set newPath to copyFolder & newName
    
    -- get the text of the template file
    set templateText to read file templateFile
    
    -- add the file name in CAPS, a colon, and 2 returns at the beginning of templateText
    set capsName to upperCase(newName)
    set newText to capsName & ":" & return & return & templateText
    
    -- write the newText to newPath
    writeTo(newPath, newText, text, false)
    
    -- open the new file in textedit
    tell application "TextEdit" to open file newPath
    
    
    
    (*============== SUBROUTINES ==============*)
    on writeTo(targetFile, theData, dataType, apendData)
        -- targetFile is the path to the file you want to write
        -- theData is the data you want in the file.
        -- dataType is the data type of theData and it can be text, list, record etc.
        -- apendData is true to append theData to the end of the current contents of the file or false to overwrite it
        try
            set targetFile to targetFile as text
            if targetFile does not contain ":" then set targetFile to POSIX file targetFile as text
            set openFile to open for access file targetFile with write permission
            if apendData is false then set eof of openFile to 0
            write theData to openFile starting at eof as dataType
            close access openFile
            return true
        on error
            try
                close access file targetFile
            end try
            return false
        end try
    end writeTo
    
    on upperCase(theText)
        set chrIDs to id of theText
        set a to {}
        repeat with i from 1 to (count of chrIDs)
            set chrID to item i of chrIDs
            if chrID ≥ 97 and chrID ≤ 122 then set chrID to (chrID - 32)
            set end of a to chrID
        end repeat
        return string id a
    end upperCase
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Edit: From another question I provided an answer that has links to a lot
Edit: Maybe I made the question more complex than it should. My questions is
Edit: I'm well aware of that this works very well with value types, my
EDIT: This question was exceptionally dumb and made me look like a script kiddie,
EDIT I made a screen shot to show better what I'm attempting to do,
EDIT: Learned that Webmethods actually uses NLST, not LIST, if that matters Our business
EDIT: This question is more about language engineering than C++ itself. I used C++
edit #2: Question solved halfways. Look below As a follow-up question, does anyone know
Edit: I have solved this by myself. See my answer below I have set
EDIT: SORRY! Turns out that I'm an idiot. The exception was being thrown from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.