Applescript - path to file

Hi there,
I was making a simple applescript... but I'm a Windows user, and I'm using a Mac environment to code some stuff to a friend and I probably am stepping onto some minor details from OSX.
Here's my question... I have these files:
So.... I have on the same folder:
Teste (the AppleScript file)
and teste.jsx (the ExtendScript file to execute some functions on InDesign).
What I was trying to do on the AS file was as simple as:
set theFileScript to "teste.jsx" as alias
tell application "Adobe InDesign CC 2014"
     do script theFileScript language javascript
end tell
But when I run it I get: "File teste.jsx wasn't found".
I already looked around and I got the idea that if I wanted a relative path (that's what we call it in Windows) to a file in the same directory we just needed to put the name of the file (just like in Windows).
But from this test and some others I did I don't think that's true, how may I solve this?
Many thanks for the help!

Code is:
set theFolder to (choose folder with prompt "Select the start folder")
set file_list to every file of theFolder
repeat with myfile in file_list
    set file_name to name of myfile
    set file_path to path of myfile
    log (file_path & "/" & file_name as string)
end repeat

Similar Messages

  • Having an AppleScript Move All Files of a Certain Type From Sub-Folders to Trash

    Greetings, everyone. With my introductory post, I would like to ask for help with an AppleScript I've been slaving over for the past five hours or so. I have tried Terminal and Finder commands both, along with lots and lots of Googling, and I cannot seem to get this to work.
    Specfically, I want a script to look into a folder and all of its sub-directories, locate all files with a certain extension (in this case, APP), and then send every one of those files to the trash. Originally, I planned to delete them directly with Terminal commands that required verification, but I couldn't get that to work, and I thought that this would be a more average user-friendly version, anyway.
    I also wondered if there was any universal means of referring to a system drive without referring to it by its name, since (as you'll see in the script) the directory that these *.app files will be moved from is in the Users/Shared hierarchy. However, it's meant to be used on multiple computers, so naming the OS drive on one won't work for others. If no such wild card exists, is what I'm doing now (having the script placed in the root folder of the OS drive) acceptable?
    As it is, when I run this script, it displays all the dialogs, but the APP files aren't moved. It doesn't error at all in the AppleScript editor, it just runs and then closes down. I don't know what I'm doing wrong.
    Thank you in advance for any help you can provide.
    =====
    if button returned of (display dialog "Trash all of the APP files in your SuchAndSuch folder? (This script must be in the root directory of your system drive.)" buttons {"Yes, I'm ready", "No"} default button 2 cancel button 2 with title "SuchAndSuch Folder Prep" with icon caution) is "Yes, I'm ready" then
        set theFolder to ":Users:Shared:SuchAndSuch:" as alias
        tell application "Finder"
            set theFiles to every file of theFolder whose name extension is "app"
            move theFiles to trash
        end tell
    end if
    if button returned of (display dialog "The APP files have been trashed." buttons {"OK"} default button 1 with title "SuchAndSuch Folder Prep" with icon 1) is "OK" then
    end if

    Well, you've done more fiddling than that; you've moved everything inside the Finder tell block.  Why did you do that?  If you recall my point 2 above, it is difficult to use POSIX paths or the POSIX file command inside Finder tell blocks without generating errors, but you've done both in your revision.  I'm surprised that you're surprised that it doesn't work. 
    Applescript tries to be user-friendly, but it's still a programming language, and like any programming language the devil is in the details.  Changes that seem small and innocuous to you can make big differences in the result you get.
    Now:
    /Users/Shared should be machine independent in POSIX: you don't need to specify the hard drive name and it should be universal on all OS X installations.  You can specify it directly.
    The Finder's delete command moves fils to the trash, it doesn't erase them.  Trying to use the move command to get files to the trash is a little bass-ackwards.
    Don't put anything inside a Finder tell block unless it has to be processed by the Finder.  If you do you're just begging for errors.
    There's no need to put the script at the root level of the drive.  If the Finder needs permission to delete a file it will ask.
    untangled and revised:
    set subfolderOfSharedFolder to quoted form of "/Users/Shared/<subfolder name>"
    set response to display dialog "Trash all of the APP files in your <subfolder name> folder?" buttons {"Yes, I'm ready", "No"} default button 2 cancel button 2 with title "<subfolder name> Folder Prep" with icon caution
    if button returned of response is "Yes, I'm ready" then
      -- run spotlight search
              set filesToDelete to paragraphs of (do shell script "mdfind 'kMDItemFSName == *.app c' -onlyin " & subfolderOfSharedFolder)
      -- convert posix paths to file specifiers
              repeat with thisFile in filesToDelete
                        set (contents of thisFile) to POSIX file thisFile
              end repeat
              tell application "Finder"
      delete filesToDelete
              end tell
              if button returned of (display dialog "The APP files have been trashed." buttons {"OK"} default button 1 with title "SuchAndSuch Folder Prep" with icon 1) is "OK" then
              end if
    end if

  • Can applescript search one file for non-matches in another file?

    I'd like to know if it's possible for Applescript to do the following:
    Take a text file with 600+ URLs and compare it to another text file with 100,000+ URLs and set out as a result any URL from the first small list that is NOT included in the second larger list?
    If it is possible to do this, is there anyone out there willing to create such a script for a modest fee?

    Hard to read the screenshot. next time cut and paste the test into the reply. Also select Replies as the display for the window in Applescript.
    The error you get, the no such file or directory are you sure that the file exists? Looks like the file is called List and it is in your desktop?
    Just tried it here and it is working OK
    Here is another copy just in case something got messed up in the first one:
              The patteren file is the smaller file with the URLs that we will lok for in the URL file
    set file1 to POSIX path of (choose file with prompt "Select patteren file:" default location alias (the path to desktop folder as text))
    set file2 to POSIX path of (choose file with prompt "Select URL file:" default location alias (the path to desktop folder as text))
    do shell script "grep -o -E '(https?|ftp|file)://.+' " & file1 & " > ~/patternFile"
    do shell script "grep -o -E '(https?|ftp|file)://.+' " & file2 & " > ~/urlFile"
    do shell script "grep -v -f ~/patternFile ~/urlFile > ~/missingUrlFile"
    --- stop copying above this line
    Just so you can see what the output in the Replies window of Applescript will look like:
    tell current application
      path to desktop as text
      --> "Mac OS Lion:Users:frank:Desktop:"
    end tell
    tell application "AppleScript Editor"
      choose file with prompt "Select patteren file:" default location alias "Mac OS Lion:Users:frank:Desktop:"
      --> alias "Mac OS Lion:Users:frank:Desktop:f1"
    end tell
    tell current application
      path to desktop as text
      --> "Mac OS Lion:Users:frank:Desktop:"
    end tell
    tell application "AppleScript Editor"
      choose file with prompt "Select URL file:" default location alias "Mac OS Lion:Users:frank:Desktop:"
      --> alias "Mac OS Lion:Users:frank:Desktop:f2"
    end tell
    tell current application
      do shell script "grep -o -E '(https?|ftp|file)://.+' /Users/frank/Desktop/f1 > ~/patternFile"
      --> ""
      do shell script "grep -o -E '(https?|ftp|file)://.+' /Users/frank/Desktop/f2 > ~/urlFile"
      --> ""
      do shell script "grep -v -f ~/patternFile ~/urlFile > ~/missingUrlFile"
      --> ""
    end tell
    Result:
    Message was edited by: Frank Caggiano - See Tony's post below

  • Unable to see the logical path and file created in FILE tcode from AL11 and unable to upload the file to this path from front end

    Hi Experts,
    I have created the logical path and filename in FILE tcode.I am trying to upload the pdf file to application server by using this path.But
    I am getting message like "Unable to open the file".Even I cannot find the this path in AL11 tcode.Kindly anyone advise how to upload pdf file using
    custom path and file created from FILE tcode.
    Thanks & Regards,
    Anusha.

    Hi Anusha,
    Please give as below.
    I forget to say you cannot open the PDF in AL11 and for that you need some configuration, i think it can be done using content server,not sure completely please wait for some more suggestions.
    Regards,
    Pavan

  • Windows Cannot Access Specific Device, Path or File While Using Adobe Reader XI, Version 11.0.06

    Hello,
    Recently, I have been experiencing a minor problem with the Adobe Reader XI Program loaded on my computer.  When clicking the data fields on PDF versions of various forms to enter numerical or text information, a dialogue box with a small white X in a red circle on the left side of the title bar pops open and is titled:
    C:\Program Files\Common Files\microsoft shared\ink\TabTip.exe
    There is another white X in a red circle symbol displayed in the message field of the dialogue box along with the following message:
    Windows cannot access the specific device, path, or file.  You may not have the appropriate permissions to access the item.
    There is also an “OK” Button displayed on the right side of the lower margin of the dialogue box.
    Although the dialogue box is repeatedly displayed whenever I click on a data field, the program still allows me to enter and save the numerical and text information that is entered in each data field.
    My computer is a Hewlett-Packard Envy 23-d034 TouchSmart All-In-One Desktop Personal Computer with a Windows 8.1 Operating System that has all applicable Important and Recommended Windows Updates installed.  The Adobe Reader XI Program is the latest version, Version 11.0.06, and I have confirmed that there are no updates for the program at this time.
    Could you suggest any recommended actions to correct this problem with the Adobe Reader XI Program?

    unfortunately no. i have a problem in my computer that doesn't let me do that.
    this is  th entire message though and it appears on the background of the program trying to load. all you can see is the frame of Rreader, and immediatly after that it shuts down

  • "File file path:to:file is already open" how do i close it?

    I am trying to write a script that pops up a dialog box, asks for text and saves this to a .csv and a .txt This is so i can quickly record what i am doing and the times i am doing it, makes quick notes and various things like that. However it is failing with the message "File file path:to:file is already open" so how do i close the file or get around this. Cheers
    Script Below
    tell me to activate
    display dialog "Enter the log message:" default answer "" buttons {"Cancel", "Ok"} default button "Ok"
    copy the result as list to {the log_message, the button_pressed}
    if the button_pressed is not "Cancel" then
    set curTime to (do shell script "date \"+%H:%M:%S\"")
    set curDate to (do shell script "date \"+%Y%m%d\"")
    set new_foldername to curDate
    set this_folder to (path to current user folder) as text
    set fPath2 to this_folder & "Documents:Logs:Date:" as alias
    --set this_folder to "Macintosh HD:Users:username:" as alias
    tell application "Finder"
    if not (exists folder new_foldername of fPath2) then
    make new folder at fPath2 with properties {name:new_foldername}
    end if
    end tell
    set fPath to (path to current user folder as Unicode text) & "Documents:Logs:Date:" & curDate & ":"
    set fName to curDate & ".csv"
    set myFile to open for access file ((fPath as string) & fName) with write permission
    write curTime & "," & log_message & return to myFile starting at eof
    close access myFile
    set fName2 to curDate & ".txt"
    set myFile to open for access file ((fPath as string) & fName2) with write permission
    write curTime & " " & log_message & return to myFile starting at eof
    close access myFile
    end if

    Hi Richard,
    Run this in the script editor:
    set f to choose file
    close access f
    Navigate to the file you left open. Probably there was an error and the file was left open because it never reached the 'close access' command.
    gl,

  • Itunes was working fine. Tries to install latest upgrade and get error message about an invalid character in the path "Program Files (x86)". PC, Win7, nothing else appears to be having same issue.

    Itunes was working fine. Tried to install latest upgrade and get error message about an invalid character in the path "Program Files (x86)". PC, Win7, nothing else appears to be having same issue. Program still works, simply cannor upgrade.

    Thanks b noir,
    I tried this solution without success. After FixIt ran and didn't find a problem, either in looking for issues with "software upgrade" or "iTunes" it kindly offered to help me uninstall iTunes. I had thought of this as a possibilty but it seems to me that if you do that you lose a lot of "non-native-to-Apple" information you might have entered. I did this once and recovery was painfull. Is there a way to uninstall iTunes without losing all of that sort of thing? Any help would be appreciated.

  • TS3212 I keep getting this error message "The folder path 'Program Files' contains an invalid character.' when upgrading itunes to Itunes 10. I could not uninstall because of the same error message. What needs to done?

    Can not download and install Itunes 10 - Get this message "The folder path 'Program Files' contain an invalid character. I tried to uninstall my old Itune through Control Panel but get the same message. What do I need to do?

    Perhaps try the following user tip with that one:
    "not a valid short file name" and "invalid character" install errors

  • ITunes fails to install update "folder path program files contains an invalid character"

    I'm trying to get the newest version of itunes, but I keep getting "the folder path program files contains an invalid character." I've seen on here before attempts to use Microsoft fix it and Windows Clean up which I've tried and both haven't helped. I've gone to youtube and tried to delete the appropriate folders under the registry edit. Nothing seems to work. I need the new itunes to update my iphone because of the recent hardware crash via the new update.

    At what stage in the process does this occur?
    For general advice see Troubleshooting issues with iTunes for Windows updates.
    The steps in the second box are a guide to removing everything related to iTunes and then rebuilding it which is often a good starting point unless the symptoms indicate a more specific approach. Review the other boxes and the list of support documents further down the page in case one of them applies.
    The further information area has direct links to the current and recent builds in case you have problems downloading, need to revert to an older version or want to try the iTunes for Windows (64-bit - for older video cards) release as a workaround for installation or performance issues, or compatibility with QuickTime or third party software.
    Your library should be unaffected by these steps but there are also links to backup and recovery advice should it be needed.
    tt2

  • ITunes Update attempt: "The folder path 'Program Files' contains an invalid character"

    How can I install the latest version when I get this message : "The folder path 'Program Files' contains an invalid character"? The message appears when I try to install the update and it appears when I try to uninstall the previous version. The instructions for manual uninstall says to use the Control Panel Uninstall Programs first and then "clean up" -- but I can't use the Control Panel Uninstall. I am running iTunes from an external drive. What to do?

    That's normally produced by a damaged iTunes.msi. The basic treatment for it is given in the following user tip:
    ["not a valid short file name" and "invalid character" install errors|http://discussions.apple.com/thread.jspa?threadID=2368028]
    ... but since Microsoft pulled the Windows Installer CleanUp utility from their Downloads Center, things have grown more difficult. First we have to find a copy of the utility.
    Let's try Googling. (Best not to use Bing, I think.) Look for a working download site for at least version 3.0 of the Windows Installer CleanUp utility. After downloading the utility installer file (msicuu2.exe), scan the file for malware, just in case. (I use the free version of Malwarebytes AntiMalware to do single-file scans for that.)
    If the file is clean, to install the utility, doubleclick the msicuu2.exe file you've downloaded.
    Now start with *step 4* from the user tip, and proceed from there.
    (If you do find a clean download site for the correct version of CleanUp, please don't tell me where it is. Without wishing to sound paranoid (although I grant it does sound paranoid), there is a non-zero chance that posting links to download locations for the utility here at Discussions leads to that download location being shut down.)

  • Error 'The Folder path 'Program Files (x86)' contains an invalid character

    I get this error (as it is in the title) when I try to install Itunes. I don't have quicktime or a previous installation of Itunes on my computer. How do I fix it?

    yes, itunes will not run without quicktime but when I try to install quicktime it says "the folder path 'program files' contains an invalid character".  have you figured it out yet?

  • Error Message:The folder path 'Program Files' contains an invalid character

    I have an 80G iPod. I never had a problem with the itunes program until I switched to Vista. When I try to open iTunes I get the following error message:
    *The folder path 'Program Files' contains an invalid character*
    I have itunes installed on both my HP and on an external hard drive that I use as my backup in case something goes wrong. Neither one opens and I get the same error message on both. I have tried to uninstall iTunes and then reinstall and get the same message so I can't uninstall.
    I'm really frustrated, I need to get to my music for a huge presentation in a few days. Can anyone help?
    Thanks in advance,
    Jejo

    Have you tried working through the steps in the General section of this article?
    http://support.apple.com/kb/HT1926

  • I cannot load I Tunes or delete it as the download stops and says the folder path "program files"contains an invalid character, what can I do?

    I cannot load or delete I Tunes from my computer. What comes up is- The folder path "program files" contain an invalid character?

    That's normally produced by a damaged iTunes.msi. The basic treatment for it is given in the following user tip:
    ["not a valid short file name" and "invalid character" install errors|http://discussions.apple.com/thread.jspa?threadID=2368028]
    ... but since Microsoft pulled the Windows Installer CleanUp utility from their Downloads Center, things have grown more difficult. First we have to find a copy of the utility.
    Let's try Googling. (Best not to use Bing, I think.) Look for a working download site for at least version 3.0 of the Windows Installer CleanUp utility. After downloading the utility installer file (msicuu2.exe), scan the file for malware, just in case. (I use the free version of Malwarebytes AntiMalware to do single-file scans for that.)
    If the file is clean, to install the utility, doubleclick the msicuu2.exe file you've downloaded.
    Now start with *step 4* from the user tip, and proceed from there.
    (If you do find a clean download site for the correct version of CleanUp, please don't tell me where it is. Without wishing to sound paranoid (although I grant it does sound paranoid), there is a non-zero chance that posting links to download locations for the utility here at Discussions leads to that download location being shut down.)

  • Working in Windows 8.1, trying to open Lightroom 3.6 64 bit, get the error message: Windows cannot access the specified device, path or file.  You may no have th appropriate permissions to access the item.

    Working in Windows 8.1, trying to open Lightroom 3.6 64 bit, get the error message: Windows cannot access the specified device, path or file.  You may no have th appropriate permissions to access the item.  I have changed the permissions to everyone and it doesn't work

    Any suggestions please?

  • How to find the absolute path of file  which store in KM foler ?

    Hello everyone:
         We want to develop an ABAP program which can write files into KM folder directly.
         So I need to find the absolute path of file which store in KM folder first, then we can consider the develop solution.
         Is this issue possbile that an ABAP  program write files into KM folder  directly ?
         Is there anybody had done this job ?
    Best Regards,
    Jianguo Chen

    Hi,
    http://forum.java.sun.com/thread.jsp?forum=34&thread=36
    612The methods in the above topic seem to be available when use a DOM parser..

Maybe you are looking for

  • ERROR CANT WRITE TO DISK

    I purchased a song and a short pxr video for my new ipod, every time i try to load on to the IPOD i get "there was an error downloading your purchased music. The Disk could not be read from or written to." I have tried both usb ports, i have reset th

  • Install PeopleTools 8.53 with Linux: psdmtx issue

    Folks, Hello. I am installing PeopleTools 8.53 Internet Architecture. Database Server is Oracle Dabase 11gR1. OS is Oracle Linux 5. I have installed JDK7, WebLogic 10.3.6, Tuxedo 11gR1 and PeopleTools 8.53 successfully. Now, I am setting up PeopleToo

  • Uniting object tables

    Hi. Could you please help me solve a problem with the following query: SELECT CAST (MULTISET (SELECT SPATIAL_TYPE (PLACE, BOUNDINGBOX) FROM (SELECT GEMETTYPE(TH_THES_NO, TH_LANG_NO, TH_DESC_NO) PLACE, BOUNDINGBOX_TYPE(NULL, NULL, NULL, NULL) BOUNDING

  • Filling space with non-visible component?

    Is there a better way to fill space to squeeze objects closer together in a gridlayout/flowlayout than simply making gui components and setting their visibility to false?

  • "Fixed" Excel chart

    Hi to all, i have a question about excel chart. I have created a simple query based on a simple infocube that read data from 2lis_11_vaitm infosource. I know that i can create charts after run the queryNow the problem. The chart, is created with a us